Class: LeafNode

Inherits:
AbsNode show all
Defined in:
lib/treevisitor/leaf_node.rb

Instance Attribute Summary

Attributes inherited from AbsNode

#name, #next, #parent, #prev

Instance Method Summary collapse

Methods inherited from AbsNode

#depth, #invalidate, #path, #path_with_prefix, #prefix_path, #prefix_path=, #root, #to_s

Constructor Details

#initialize(name, parent = nil) ⇒ LeafNode

Returns a new instance of LeafNode.



5
6
7
8
9
10
# File 'lib/treevisitor/leaf_node.rb', line 5

def initialize( name, parent = nil )
  super( name )
  if parent
    parent.add_leaf( self ) 
  end
end

Instance Method Details

#accept(visitor) ⇒ Object

return the visitor



21
22
23
24
# File 'lib/treevisitor/leaf_node.rb', line 21

def accept( visitor )
  visitor.visit_leaf_node( self )
  visitor
end

#root?Boolean

a leaf_node cannot be a root

Returns:

  • (Boolean)


14
15
16
# File 'lib/treevisitor/leaf_node.rb', line 14

def root?
  false
end