Class: Locomotive::AstHelpers::PreOrderTraverse
- Inherits:
-
TraverseStrategy
- Object
- TraverseStrategy
- Locomotive::AstHelpers::PreOrderTraverse
- Defined in:
- lib/locomotive/tree_helpers/ast_traversal.rb
Class Method Summary collapse
Class Method Details
.traverse(ast, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/locomotive/tree_helpers/ast_traversal.rb', line 12 def PreOrderTraverse.traverse(ast, &block) block.call(ast) traverse(ast.left_child, &block) if ast.has_left_child? traverse(ast.right_child, &block) if ast.has_right_child? # return nothing return end |