Class: Mutant::Walker

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/walker.rb

Overview

Walker for all ast nodes

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, block) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize and run walker

Parameters:

  • root (Parser::AST::Node)
  • block (#call(node))


32
33
34
35
# File 'lib/mutant/walker.rb', line 32

def initialize(root, block)
  @root, @block = root, block
  dispatch(root)
end

Class Method Details

.run(root, &block) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run walkter

Parameters:

  • root (Parser::AST::Node)

Returns:

  • (self)


16
17
18
19
# File 'lib/mutant/walker.rb', line 16

def self.run(root, &block)
  new(root, block)
  self
end