Class: LeafNode
Instance Attribute Summary
Attributes inherited from AbsNode
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
return the visitor.
-
#initialize(name, parent = nil) ⇒ LeafNode
constructor
A new instance of LeafNode.
-
#root? ⇒ Boolean
a leaf_node cannot be a root.
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
14 15 16 |
# File 'lib/treevisitor/leaf_node.rb', line 14 def root? false end |