Class: Wash::Streamer
- Inherits:
-
Object
- Object
- Wash::Streamer
- Defined in:
- lib/wash/streamer.rb
Overview
Streamer is a class meant to be used by implementations of Wash::Entry#stream.
Instance Method Summary collapse
-
#initialize ⇒ Streamer
constructor
A new instance of Streamer.
-
#write(chunk) ⇒ Object
write writes the given chunk to STDOUT then flushes it to ensure that Wash receives the data.
Constructor Details
#initialize ⇒ Streamer
Returns a new instance of Streamer.
6 7 8 |
# File 'lib/wash/streamer.rb', line 6 def initialize @first_chunk = true end |
Instance Method Details
#write(chunk) ⇒ Object
write writes the given chunk to STDOUT then flushes it to ensure that Wash receives the data. If the chunk is the first chunk that’s written, then write will print the “200” header prior to writing the chunk.
15 16 17 18 19 20 21 22 |
# File 'lib/wash/streamer.rb', line 15 def write(chunk) if @first_chunk puts("200") @first_chunk = false end $stdout.print(chunk) $stdout.flush end |