Class: Locomotive::AstHelpers::PostOrderTraverse

Inherits:
TraverseStrategy show all
Defined in:
lib/locomotive/tree_helpers/ast_traversal.rb

Class Method Summary collapse

Class Method Details

.traverse(ast, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/locomotive/tree_helpers/ast_traversal.rb', line 22

def PostOrderTraverse.traverse(ast, &block)
  traverse(ast.left_child,  &block) if ast.has_left_child?
  traverse(ast.right_child, &block) if ast.has_right_child?
  block.call(ast)
  # return nothing
  return
end