Module: CodeNode::IR::Node::TemplateMethods
- Included in:
- CodeNode::IR::Node
- Defined in:
- lib/code_node/ir/node.rb
Overview
Node methods which are useful in templates
Instance Attribute Summary collapse
-
#children ⇒ Hash<String,Node>
readonly
The child nodes of this node.
-
#name ⇒ String
readonly
The name of the node.
-
#parent ⇒ Node
readonly
Node which contains this node.
Instance Method Summary collapse
-
#extensions ⇒ Array<Node>
Module nodes for which this node has an
extendstatement. -
#inclusions ⇒ Array<Node>
Module nodes for which this node has an
includestatement. -
#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.
-
#stamp_styles ⇒ String
Stamp the accumulated GraphViz styles in a format suitable for inclusion in a
.dotfile. -
#super_class_node ⇒ Node?
The super class of this class.
Instance Attribute Details
#children ⇒ Hash<String,Node> (readonly)
The child nodes of this node
36 37 38 |
# File 'lib/code_node/ir/node.rb', line 36 def children @children end |
#name ⇒ String (readonly)
Returns the name of the node. Not necessarilly unique.
17 18 19 |
# File 'lib/code_node/ir/node.rb', line 17 def name @name end |
#parent ⇒ Node (readonly)
Returns node which contains this node.
25 26 27 |
# File 'lib/code_node/ir/node.rb', line 25 def parent @parent end |
Instance Method Details
#extensions ⇒ Array<Node>
Returns module nodes for which this node has an extend statement.
49 50 51 |
# File 'lib/code_node/ir/node.rb', line 49 def extensions @extends.values.sort end |
#inclusions ⇒ Array<Node>
Returns module nodes for which this node has an include statement.
44 45 46 |
# File 'lib/code_node/ir/node.rb', line 44 def inclusions @includes.values.sort end |
#key ⇒ String
Returns fully qualified identifier for the node in the form Foo_Bar_Car. Ideal for graphviz identifiers.
54 55 56 |
# File 'lib/code_node/ir/node.rb', line 54 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.
59 60 61 |
# File 'lib/code_node/ir/node.rb', line 59 def label @parent.nil? ? path : name end |
#stamp_styles ⇒ String
Stamp the accumulated GraphViz styles in a format suitable for inclusion in a .dot file
65 66 67 68 69 70 71 |
# File 'lib/code_node/ir/node.rb', line 65 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.
39 40 41 |
# File 'lib/code_node/ir/node.rb', line 39 def super_class_node @inherits_from end |