Class: Locomotive::AstHelpers::InOrderTraverse

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

Class Method Summary collapse

Class Method Details

.traverse(ast, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/locomotive/tree_helpers/ast_traversal.rb', line 32

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