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, #gets, #read, #readpartial, #to_io
Constructor Details
#initialize(io, buffer_limit = 1024*16) ⇒ WriteBufferStream
Returns a new instance of WriteBufferStream.
47 48 49 50 51 |
# File 'lib/riser/stream.rb', line 47 def initialize(io, buffer_limit=1024*16) super(io) @buffer_limit = buffer_limit @buffer_string = ''.b end |
Instance Method Details
#flush ⇒ Object
70 71 72 73 |
# File 'lib/riser/stream.rb', line 70 def flush write_and_flush unless @buffer_string.empty? self end |
#write(message) ⇒ Object
65 66 67 68 |
# File 'lib/riser/stream.rb', line 65 def write() @buffer_string << .b write_and_flush if (@buffer_string.bytesize >= @buffer_limit) end |