Method: Async::IO::Stream#write

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

#write(string) ⇒ Object

Writes string to the buffer. When the buffer is full or #sync is true the buffer is flushed to the underlying io.

Parameters:

  • string

    the string to write to the buffer.

Returns:

  • the number of bytes appended to the buffer.



172
173
174
175
176
177
178
179
180
# File 'lib/async/io/stream.rb', line 172

def write(string)
  @write_buffer << string
  
  if @write_buffer.bytesize >= @block_size
    flush
  end
  
  return string.bytesize
end