Class: Reru::StreamConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/reru/stream_consumer.rb

Instance Method Summary collapse

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