Class: TreeRb::BlockTreeNodeVisitor

Inherits:
BasicTreeNodeVisitor show all
Defined in:
lib/tree_rb/visitors/block_tree_node_visitor.rb

Overview

It calls a block when visit a tree_node or leaf_node

Instance Method Summary collapse

Methods inherited from BasicTreeNodeVisitor

#cannot_enter_node, #cannot_visit_leaf, #exit_node

Constructor Details

#initialize(&action) ⇒ BlockTreeNodeVisitor

Returns a new instance of BlockTreeNodeVisitor.



8
9
10
# File 'lib/tree_rb/visitors/block_tree_node_visitor.rb', line 8

def initialize( &action )
  @block = action
end

Instance Method Details

#enter_node(tree_node) ⇒ Object



12
13
14
# File 'lib/tree_rb/visitors/block_tree_node_visitor.rb', line 12

def enter_node( tree_node )
  @block.call( tree_node )
end

#visit_leaf(leaf_node) ⇒ Object



16
17
18
# File 'lib/tree_rb/visitors/block_tree_node_visitor.rb', line 16

def visit_leaf( leaf_node )
  @block.call( leaf_node )
end