Class: TreeRb::LeafNode

Inherits:
AbsNode show all
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

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.

Parameters:

  • content (Object)

    of node



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.

Returns:



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.

Returns:

  • (Boolean)

    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