Class: LabeledNode
- Inherits:
-
AbstractNode
- Object
- AbstractNode
- LabeledNode
- Includes:
- Concrete
- Defined in:
- lib/labeled_node.rb
Instance Attribute Summary
Attributes inherited from AbstractNode
Instance Method Summary collapse
-
#initialize(data = nil, *sub_nodes) ⇒ LabeledNode
constructor
A new instance of LabeledNode.
- #merge!(sub_nodes) ⇒ Object
Methods included from Concrete
Methods inherited from AbstractNode
#[], #[]=, #delete, #each_index, #each_node, #each_pair, #leaf?, #nb_sub_nodes, #pre_depth_first
Methods included from Abstract
Constructor Details
#initialize(data = nil, *sub_nodes) ⇒ LabeledNode
Returns a new instance of LabeledNode.
12 13 14 15 16 17 18 19 |
# File 'lib/labeled_node.rb', line 12 def initialize(data=nil, *sub_nodes) if sub_nodes.empty? @sub_nodes = {} else @sub_nodes = sub_nodes.first end super end |
Instance Method Details
#merge!(sub_nodes) ⇒ Object
21 22 23 24 |
# File 'lib/labeled_node.rb', line 21 def merge!(sub_nodes) sub_nodes.each { |index, sub_node| check_sub_node_type(sub_node) } @sub_nodes.merge(sub_nodes) end |