Class: Rewire::Pipe

Inherits:
Object
  • Object
show all
Defined in:
lib/rewire/pipe.rb

Instance Method Summary collapse

Constructor Details

#initialize(&logic) ⇒ Pipe

Returns a new instance of Pipe.



3
4
5
# File 'lib/rewire/pipe.rb', line 3

def initialize(&logic)
  @logic = logic
end

Instance Method Details

#<<(pack) ⇒ Object



11
12
13
14
15
# File 'lib/rewire/pipe.rb', line 11

def <<(pack)
  output = []
  (self | output) << pack
  output
end

#process(receiver, pack) ⇒ Object



17
18
19
# File 'lib/rewire/pipe.rb', line 17

def process(receiver, pack)
  @logic[receiver, pack]
end

#|(pipe) ⇒ Object



7
8
9
# File 'lib/rewire/pipe.rb', line 7

def |(pipe)
  Emitter.new(self) | pipe
end