Class: Reru::Stream

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/reru/stream.rb,
lib/reru/stream.rb

Overview

before we require all of the subclasses, we need to have Stream defined

Direct Known Subclasses

EnumerableStream, Log, Map, Select

Instance Method Summary collapse

Constructor Details

#initialize(*sources) ⇒ Stream

Returns a new instance of Stream.



16
17
18
# File 'lib/reru/stream.rb', line 16

def initialize(*sources)
  Reru::Dispatcher.new(*sources).each { |event| dispatch(event) }
end

Instance Method Details

#consume(&block) ⇒ Object



35
36
37
# File 'lib/reru/stream.rb', line 35

def consume(&block)
  Reru::StreamConsumer.new(self, &block)
end

#dispatch(event) ⇒ Object



22
23
24
# File 'lib/reru/stream.rb', line 22

def dispatch(event)
  emit(event)    
end

#emit(event) ⇒ Object



26
27
28
29
# File 'lib/reru/stream.rb', line 26

def emit(event)
  changed
  notify_observers(self, event)
end

#logObject



47
48
49
# File 'lib/reru/stream.rb', line 47

def log
  Reru::Log.new(self)
end

#map(&block) ⇒ Object



43
44
45
# File 'lib/reru/stream.rb', line 43

def map(&block)
  Reru::Map.new(self, &block)
end

#merge(right) ⇒ Object



31
32
33
# File 'lib/reru/stream.rb', line 31

def merge(right)
  Reru::Stream.new(self, right)
end

#select(&block) ⇒ Object



39
40
41
# File 'lib/reru/stream.rb', line 39

def select(&block)
  Reru::Select.new(self, &block)
end

#to_esObject



20
# File 'lib/reru/stream.rb', line 20

def to_es ; self ; end