Class: Reru::StreamConsumer
- Inherits:
-
Object
- Object
- Reru::StreamConsumer
- Defined in:
- lib/reru/stream_consumer.rb
Instance Method Summary collapse
-
#initialize(source, &block) ⇒ StreamConsumer
constructor
A new instance of StreamConsumer.
- #update(source, event) ⇒ Object
Constructor Details
#initialize(source, &block) ⇒ StreamConsumer
Returns a new instance of StreamConsumer.
2 3 4 5 |
# File 'lib/reru/stream_consumer.rb', line 2 def initialize(source, &block) @block = block source.add_observer(self) end |
Instance Method Details
#update(source, event) ⇒ Object
7 8 9 10 |
# File 'lib/reru/stream_consumer.rb', line 7 def update(source, event) return if event.eos? @block.call(event.value) end |