Module: CodeNode::IR::Node::TemplateMethods
- Included in:
- CodeNode::IR::Node
- Defined in:
- lib/code_node/ir/node/template_methods.rb
Overview
Node methods which are useful in templates
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the node.
Instance Method Summary collapse
-
#children ⇒ Hash<String,Node>
The child nodes of this node.
-
#extensions ⇒ Array<Node>
Module nodes for which this node has an
extend
statement. -
#inclusions ⇒ Array<Node>
Module nodes for which this node has an
include
statement. -
#key ⇒ String
Fully qualified identifier for the node in the form
Foo_Bar_Car
. -
#label ⇒ String
How the node will be labelled in the graph.
-
#parent ⇒ Node
Node which contains this node.
-
#stamp_styles ⇒ String
Stamp the accumulated GraphViz styles in a format suitable for inclusion in a
.dot
file. -
#super_class_node ⇒ Node?
The super class of this class.
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the node. Not necessarilly unique.
10 11 12 |
# File 'lib/code_node/ir/node/template_methods.rb', line 10 def name @name end |
Instance Method Details
#children ⇒ Hash<String,Node>
The child nodes of this node
31 32 33 |
# File 'lib/code_node/ir/node/template_methods.rb', line 31 def children @edge[:children] end |
#extensions ⇒ Array<Node>
Returns module nodes for which this node has an extend
statement.
46 47 48 |
# File 'lib/code_node/ir/node/template_methods.rb', line 46 def extensions @edge[:extends].values.sort end |
#inclusions ⇒ Array<Node>
Returns module nodes for which this node has an include
statement.
41 42 43 |
# File 'lib/code_node/ir/node/template_methods.rb', line 41 def inclusions @edge[:includes].values.sort end |
#key ⇒ String
Returns fully qualified identifier for the node in the form Foo_Bar_Car
. Ideal for graphviz identifiers.
51 52 53 |
# File 'lib/code_node/ir/node/template_methods.rb', line 51 def key @path.join '_' end |
#label ⇒ String
Returns how the node will be labelled in the graph. Nodes without parents display their full QueryMethods#path, while nodes with parents only display their #name.
56 57 58 |
# File 'lib/code_node/ir/node/template_methods.rb', line 56 def label parent.nil? ? path : name end |
#parent ⇒ Node
Returns node which contains this node.
18 19 20 |
# File 'lib/code_node/ir/node/template_methods.rb', line 18 def parent @edge[:parent].values.first end |
#stamp_styles ⇒ String
Stamp the accumulated GraphViz styles in a format suitable for inclusion in a .dot
file
62 63 64 65 66 67 68 |
# File 'lib/code_node/ir/node/template_methods.rb', line 62 def stamp_styles x = [] style.each_pair do |key, value| x << "#{key}=\"#{value}\"" end x.join ' ' end |
#super_class_node ⇒ Node?
Returns the super class of this class. Will be nil
for modules.
36 37 38 |
# File 'lib/code_node/ir/node/template_methods.rb', line 36 def super_class_node @edge[:inherits_from].values.first end |