Class: Riser::WriteBufferStream
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(io, buffer_limit = 1024*16) ⇒ WriteBufferStream
constructor
A new instance of WriteBufferStream.
- #write(message) ⇒ Object
Methods inherited from Stream
#<<, #close, #read, #readpartial, #to_io
Constructor Details
#initialize(io, buffer_limit = 1024*16) ⇒ WriteBufferStream
Returns a new instance of WriteBufferStream.
55 56 57 58 59 |
# File 'lib/riser/stream.rb', line 55 def initialize(io, buffer_limit=1024*16) super(io) @buffer_limit = buffer_limit @buffer_string = ''.b end |
Instance Method Details
#flush ⇒ Object
78 79 80 81 |
# File 'lib/riser/stream.rb', line 78 def flush write_and_flush unless @buffer_string.empty? self end |
#write(message) ⇒ Object
73 74 75 76 |
# File 'lib/riser/stream.rb', line 73 def write() @buffer_string << .b write_and_flush if (@buffer_string.bytesize >= @buffer_limit) end |