Class: Aqueductron::Piece
- Inherits:
-
Object
- Object
- Aqueductron::Piece
- Includes:
- PieceCommon
- Defined in:
- lib/aqueductron/piece.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
Instance Method Summary collapse
- #eof ⇒ Object
-
#initialize(destination, what_to_do) ⇒ Piece
constructor
A new instance of Piece.
- #pass_on(msg, what_to_do_next) ⇒ Object
- #receive(msg) ⇒ Object
- #send_eof ⇒ Object
Methods included from PieceCommon
Constructor Details
#initialize(destination, what_to_do) ⇒ Piece
Returns a new instance of Piece.
8 9 10 11 |
# File 'lib/aqueductron/piece.rb', line 8 def initialize(destination, what_to_do) @destination = destination @what_to_do = what_to_do end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
5 6 7 |
# File 'lib/aqueductron/piece.rb', line 5 def destination @destination end |
Instance Method Details
#eof ⇒ Object
17 18 19 |
# File 'lib/aqueductron/piece.rb', line 17 def eof send_eof end |
#pass_on(msg, what_to_do_next) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/aqueductron/piece.rb', line 21 def pass_on(msg, what_to_do_next) next_destination = @destination.receive(msg) if (next_destination.result?) then next_destination else Piece.new(next_destination, what_to_do_next) end end |
#receive(msg) ⇒ Object
13 14 15 |
# File 'lib/aqueductron/piece.rb', line 13 def receive(msg) @what_to_do.call(self, msg) end |
#send_eof ⇒ Object
29 30 31 |
# File 'lib/aqueductron/piece.rb', line 29 def send_eof @destination.eof end |