Class: CompSci::ChildFlexNode
- Defined in:
- lib/compsci/node.rb
Overview
ChildNode which accumulates children with no gaps It meets the FlexNode API but does not inherit from FlexNode since it needs to reimplement each method; instead get parent stuff from ChildNode
Instance Attribute Summary
Attributes inherited from ChildNode
Attributes inherited from Node
Instance Method Summary collapse
Methods inherited from ChildNode
#gen, #initialize, #set_child, #set_parent, #siblings
Methods inherited from Node
#initialize, #inspect, #set_child, #to_s
Constructor Details
This class inherits a constructor from CompSci::ChildNode
Instance Method Details
#add_child(node) ⇒ Object
102 103 104 105 106 |
# File 'lib/compsci/node.rb', line 102 def add_child(node) node.parent ||= self raise "node has a parent: #{node.parent}" if node.parent != self @children << node end |
#add_parent(node) ⇒ Object
112 113 114 115 |
# File 'lib/compsci/node.rb', line 112 def add_parent(node) @parent = node @parent.add_child(self) end |
#new_child(value) ⇒ Object
108 109 110 |
# File 'lib/compsci/node.rb', line 108 def new_child(value) self.add_child self.class.new(value) end |