Class: LeafNode

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

Overview

Deriva da AbsNode

definisce un metodo to_str

Instance Attribute Summary

Attributes inherited from AbsNode

#name, #next, #parent, #prev

Instance Method Summary collapse

Methods inherited from AbsNode

#depth, #invalidate, #path, #path_from_root, #prefix_path, #prefix_path=, #root

Constructor Details

#initialize(name, parent = nil) ⇒ LeafNode

Returns a new instance of LeafNode.



12
13
14
15
16
17
# File 'lib/tree_visitor/leaf_node.rb', line 12

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

Instance Method Details

#accept(visitor) ⇒ Object



19
20
21
# File 'lib/tree_visitor/leaf_node.rb', line 19

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

#to_strObject



23
24
25
# File 'lib/tree_visitor/leaf_node.rb', line 23

def to_str
  name.to_str
end