Class: GraphBuilder::Chain
Instance Attribute Summary
Attributes inherited from Base
#children, #opts, #parent
Instance Method Summary
collapse
Methods inherited from Node
#add_leaf, #add_node, #to_s
Methods inherited from Base
#ancestors, #debug, #depth, #dump, #empty?, #indent, #initialize
Instance Method Details
#first_things ⇒ Object
67
|
# File 'lib/graph_builder.rb', line 67
def first_things; children.map(&:first_things).first; end
|
#last_things ⇒ Object
66
|
# File 'lib/graph_builder.rb', line 66
def last_things; children.map(&:last_things).last; end
|
#process ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/graph_builder.rb', line 69
def process
children.each &:process
debug{"processing #{self}"}
debug{" children: #{children.map(&:to_s).join(',')}" }
children.each_cons(2) do |pair|
debug{" pair: (#{pair.first},#{pair.last})"}
froms = [pair.first.last_things].flatten
tos = [pair.last.first_things].flatten
debug{" froms= last_things of #{pair.first}: #{froms.map(&:to_s).join(',')}"}
debug{" tos= first_things of #{pair.last}: #{tos.map(&:to_s).join(',')}"}
tos.each do |to|
froms.each do |from|
debug{" link from=#{from} to=#{to}"}
from.link_to to
end
end
end
end
|