Class: Reru::Map

Inherits:
Stream show all
Defined in:
lib/reru/map.rb

Instance Method Summary collapse

Methods inherited from Stream

#consume, #dispatch, #log, #map, #merge, #select, #to_es

Constructor Details

#initialize(source, &block) ⇒ Map

Returns a new instance of Map.



5
6
7
8
# File 'lib/reru/map.rb', line 5

def initialize(source, &block)
  super(source)
  @block = block
end

Instance Method Details

#emit(event) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/reru/map.rb', line 10

def emit(event)
  if event.value?
    super Reru::Next.new(@block.call(event.value)) if @block.call(event.value)
  else
    super
  end
end