Class: Dendroid::Parsing::CompositeParseNode
- Defined in:
- lib/dendroid/parsing/composite_parse_node.rb
Overview
Composite Pattern. A specialization of parse nodes that have themselves children nodes.
Instance Attribute Summary collapse
-
#children ⇒ Array<Dendroid::Parsing::ParseNode|NilClass>
readonly
Sub-nodes.
Attributes inherited from ParseNode
Instance Method Summary collapse
- #add_child(child_node, index) ⇒ Object
-
#initialize(lowerBound, upperBound, child_count) ⇒ CompositeParseNode
constructor
A new instance of CompositeParseNode.
Constructor Details
#initialize(lowerBound, upperBound, child_count) ⇒ CompositeParseNode
Returns a new instance of CompositeParseNode.
15 16 17 18 |
# File 'lib/dendroid/parsing/composite_parse_node.rb', line 15 def initialize(lowerBound, upperBound, child_count) super(lowerBound, upperBound) @children = Array.new(child_count, nil) end |
Instance Attribute Details
#children ⇒ Array<Dendroid::Parsing::ParseNode|NilClass> (readonly)
Returns Sub-nodes. Nil values represent available slots.
10 11 12 |
# File 'lib/dendroid/parsing/composite_parse_node.rb', line 10 def children @children end |
Instance Method Details
#add_child(child_node, index) ⇒ Object
20 21 22 |
# File 'lib/dendroid/parsing/composite_parse_node.rb', line 20 def add_child(child_node, index) children[index] = child_node end |