Class: LabeledNode

Inherits:
AbstractNode show all
Includes:
Concrete
Defined in:
lib/labeled_node.rb

Instance Attribute Summary

Attributes inherited from AbstractNode

#data, #sub_nodes

Instance Method Summary collapse

Methods included from Concrete

included

Methods inherited from AbstractNode

#[], #[]=, #delete, #each_index, #each_node, #each_pair, #leaf?, #nb_sub_nodes, #pre_depth_first

Methods included from Abstract

included

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