Module: CodeNode::IR::Graph::TemplateMethods
- Included in:
- CodeNode::IR::Graph
- Defined in:
- lib/code_node/ir/graph/template_methods.rb
Overview
CodeNode::IR::Graph methods which are useful in templates
Instance Method Summary collapse
-
#each_class {|node| ... } ⇒ nil
Iterate through each Node with Node::QueryMethods#class? in the graph.
-
#each_containment {|a, b| ... } ⇒ nil
Iterate through each containment relation in the graph.
-
#each_extension {|a, b| ... } ⇒ nil
Iterate through each extension relation in the graph.
-
#each_inclusion {|a, b| ... } ⇒ nil
Iterate through each inclusion relation in the graph.
-
#each_inheritance {|a, b| ... } ⇒ nil
Iterate through each inheritance relation in the graph.
-
#each_module {|node| ... } ⇒ nil
Iterate through each Node with Node::QueryMethods#module? in the graph.
Instance Method Details
#each_class {|node| ... } ⇒ nil
Iterate through each Node with Node::QueryMethods#class? in the graph
11 12 13 14 15 |
# File 'lib/code_node/ir/graph/template_methods.rb', line 11 def each_class(&block) @nodes.values.select do |node| node.class? end.sort.each &block end |
#each_containment {|a, b| ... } ⇒ nil
Iterate through each containment relation in the graph
36 37 38 39 40 41 42 |
# File 'lib/code_node/ir/graph/template_methods.rb', line 36 def each_containment(&block) @nodes.values.sort.each do |node| if node.parent block.call node.parent, node end end end |
#each_extension {|a, b| ... } ⇒ nil
Iterate through each extension relation in the graph
86 87 88 89 90 91 92 |
# File 'lib/code_node/ir/graph/template_methods.rb', line 86 def each_extension(&block) @nodes.values.sort.each do |node| node.extensions.each do |other| block.call node, other end end end |
#each_inclusion {|a, b| ... } ⇒ nil
Iterate through each inclusion relation in the graph
69 70 71 72 73 74 75 |
# File 'lib/code_node/ir/graph/template_methods.rb', line 69 def each_inclusion(&block) @nodes.values.sort.each do |node| node.inclusions.each do |other| block.call node, other end end end |
#each_inheritance {|a, b| ... } ⇒ nil
Iterate through each inheritance relation in the graph
52 53 54 55 56 57 58 |
# File 'lib/code_node/ir/graph/template_methods.rb', line 52 def each_inheritance(&block) @nodes.values.sort.each do |node| if node.super_class_node block.call node, node.super_class_node end end end |
#each_module {|node| ... } ⇒ nil
Iterate through each Node with Node::QueryMethods#module? in the graph
20 21 22 23 24 |
# File 'lib/code_node/ir/graph/template_methods.rb', line 20 def each_module(&block) @nodes.values.select do |node| node.module? end.sort.each &block end |