Class: TreeRb::LeafNode
- Defined in:
- lib/tree_rb/core/leaf_node.rb
Overview
Represent a LeafNode
Instance Attribute Summary
Attributes inherited from AbsNode
#content, #next, #parent, #prev
Instance Method Summary collapse
-
#accept(visitor) ⇒ TreeNodeVisitor
The visitor.
-
#initialize(content, parent = nil) ⇒ LeafNode
constructor
A new instance of LeafNode.
-
#root? ⇒ Boolean
False because a leaf_node cannot be a root.
Methods inherited from AbsNode
#depth, #invalidate, #path, #path_with_prefix, #prefix_path, #prefix_path=, #root
Constructor Details
#initialize(content, parent = nil) ⇒ LeafNode
Returns a new instance of LeafNode.
12 13 14 15 |
# File 'lib/tree_rb/core/leaf_node.rb', line 12 def initialize( content, parent = nil ) super( content ) parent.add_leaf(self) if parent end |
Instance Method Details
#accept(visitor) ⇒ TreeNodeVisitor
Returns the visitor.
27 28 29 30 |
# File 'lib/tree_rb/core/leaf_node.rb', line 27 def accept( visitor ) visitor.visit_leaf( self ) visitor end |
#root? ⇒ Boolean
Returns false because a leaf_node cannot be a root.
20 21 22 |
# File 'lib/tree_rb/core/leaf_node.rb', line 20 def root? false end |