class NIO::ByteBuffer

def read_from(io)

Returns:
  • (Integer) - number of bytes read (0 if none were available)

Parameters:
  • Ruby (IO) -- IO object to read from
def read_from(io)
  nbytes = @limit - @position
  raise OverflowError, "buffer is full" if nbytes.zero?
  bytes_read = IO.try_convert(io).read_nonblock(nbytes, exception: false)
  return 0 if bytes_read == :wait_readable
  self << bytes_read
  bytes_read.length
end