class UbyInterpreter::Environment

Public Class Methods

new() click to toggle source
# File lib/uby_interpreter.rb, line 31
def initialize
  @env = [{}]
end

Public Instance Methods

[](k) click to toggle source
# File lib/uby_interpreter.rb, line 11
def [] k
  self.all[k]
end
[]=(k, v) click to toggle source
# File lib/uby_interpreter.rb, line 15
def []= k, v
  @env.last[k] = v
end
all() click to toggle source
# File lib/uby_interpreter.rb, line 19
def all
  @env.inject(&:merge)
end
scope() { || ... } click to toggle source
# File lib/uby_interpreter.rb, line 23
def scope
  @env.push({})

  yield
ensure
  @env.pop
end