Class: Aqueductron::JointPiece

Inherits:
Object
  • Object
show all
Includes:
PieceCommon
Defined in:
lib/aqueductron/joint_piece.rb

Instance Method Summary collapse

Methods included from PieceCommon

#flow, #result?

Constructor Details

#initialize(paths) ⇒ JointPiece

Returns a new instance of JointPiece.



6
7
8
# File 'lib/aqueductron/joint_piece.rb', line 6

def initialize(paths)
  @paths = paths
end

Instance Method Details

#eofObject



21
22
23
24
25
# File 'lib/aqueductron/joint_piece.rb', line 21

def eof
  go = ->(v) { v.result? ? v : v.eof }
  new_map = @paths.map_values(&go)
  construct_compound_result(new_map)
end

#receive(msg) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/aqueductron/joint_piece.rb', line 11

def receive(msg)
  go = ->(v) { v.result? ? v : v.receive(msg) }
  new_map = @paths.map_values(&go)
  if (new_map.values.all? &:result? )
    construct_compound_result(new_map)
  else
    JointPiece.new(new_map)
  end
end