Class: Procedo::Engine::Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/procedo/engine/interpreter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(intervention, env = {}) ⇒ Interpreter

Returns a new instance of Interpreter.


8
9
10
11
12
13
14
15
# File 'lib/procedo/engine/interpreter.rb', line 8

def initialize(intervention, env = {})
  @intervention = intervention
  @env = env.each_with_object({}) do |(k, v), h|
    h[k.to_s.upcase] = v
    h
  end
  # puts @env.map { |k, v| k.to_s.red + ': ' + v.class.name.yellow }.join(', ')
end

Class Method Details

.interpret(intervention, tree, env = {}) ⇒ Object


4
5
6
# File 'lib/procedo/engine/interpreter.rb', line 4

def self.interpret(intervention, tree, env = {})
  new(intervention, env).interpret(tree)
end

Instance Method Details

#interpret(node) ⇒ Object


17
18
19
20
# File 'lib/procedo/engine/interpreter.rb', line 17

def interpret(node)
  @variables = []
  run(node)
end