Class: Cadenza::BlockNode
- Inherits:
-
Object
- Object
- Cadenza::BlockNode
- Defined in:
- lib/cadenza/nodes/block_node.rb
Overview
The BlockNode is a general container with a given name meant to implement Cadenza’s template inheritance feature. Blocks defined in a template will override the definition of blocks defined in the parent template.
Instance Attribute Summary collapse
-
#children ⇒ Array
The child nodes belonging to this block.
-
#name ⇒ String
The name of the node.
Instance Method Summary collapse
-
#==(rhs) ⇒ Boolean
True if the given BlockNode is equivalent to the this node by value.
-
#implied_globals ⇒ Array
A list of any implied global variable names defined by this block’s children.
-
#initialize(name, children = []) ⇒ BlockNode
constructor
creates a new block node with the given name and child nodes.
Constructor Details
#initialize(name, children = []) ⇒ BlockNode
creates a new block node with the given name and child nodes
15 16 17 18 |
# File 'lib/cadenza/nodes/block_node.rb', line 15 def initialize(name, children=[]) @name = name @children = children end |
Instance Attribute Details
#children ⇒ Array
Returns the child nodes belonging to this block.
10 11 12 |
# File 'lib/cadenza/nodes/block_node.rb', line 10 def children @children end |
#name ⇒ String
Returns the name of the node.
7 8 9 |
# File 'lib/cadenza/nodes/block_node.rb', line 7 def name @name end |
Instance Method Details
#==(rhs) ⇒ Boolean
Returns true if the given Cadenza::BlockNode is equivalent to the this node by value.
29 30 31 32 |
# File 'lib/cadenza/nodes/block_node.rb', line 29 def ==(rhs) @name == rhs.name and @children == rhs.children end |
#implied_globals ⇒ Array
Returns a list of any implied global variable names defined by this block’s children.
22 23 24 |
# File 'lib/cadenza/nodes/block_node.rb', line 22 def implied_globals @children.map(&:implied_globals).flatten.uniq end |