Method: Async::IO::Stream#read_partial

Defined in:
lib/async/io/stream.rb

#read_partial(size = nil) ⇒ Object Also known as: readpartial

Read at most size bytes from the stream. Will avoid reading from the underlying stream if possible.



95
96
97
98
99
100
101
102
103
# File 'lib/async/io/stream.rb', line 95

def read_partial(size = nil)
  return String.new(encoding: Encoding::BINARY) if size == 0

  if !@eof and @read_buffer.empty?
    fill_read_buffer
  end
  
  return consume_read_buffer(size)
end