Class: Rbsiev::Environment::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/rbsiev/environment.rb

Instance Method Summary collapse

Constructor Details

#initialize(variables = [], values = []) ⇒ Frame



17
18
19
# File 'lib/rbsiev/environment.rb', line 17

def initialize(variables = [], values = [])
  @bindings = variables.zip(values).to_h
end

Instance Method Details

#add_binding(var, val) ⇒ Object



33
34
35
# File 'lib/rbsiev/environment.rb', line 33

def add_binding(var, val)
  @bindings.merge!({var => val})
end

#lookup(var) ⇒ Object



29
30
31
# File 'lib/rbsiev/environment.rb', line 29

def lookup(var)
  @bindings[var]
end

#set(var, value) ⇒ Object



37
38
39
# File 'lib/rbsiev/environment.rb', line 37

def set(var, value)
  @bindings[var] = value
end

#valuesObject



25
26
27
# File 'lib/rbsiev/environment.rb', line 25

def values
  @bindings.values
end

#variablesObject



21
22
23
# File 'lib/rbsiev/environment.rb', line 21

def variables
  @bindings.keys
end