Class: Rbsiev::Environment::Frame
- Inherits:
-
Object
- Object
- Rbsiev::Environment::Frame
- Defined in:
- lib/rbsiev/environment.rb
Instance Method Summary collapse
- #add_binding(var, val) ⇒ Object
-
#initialize(variables = [], values = []) ⇒ Frame
constructor
A new instance of Frame.
- #lookup(var) ⇒ Object
- #set(var, value) ⇒ Object
- #values ⇒ Object
- #variables ⇒ Object
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 |
#values ⇒ Object
25 26 27 |
# File 'lib/rbsiev/environment.rb', line 25 def values @bindings.values end |
#variables ⇒ Object
21 22 23 |
# File 'lib/rbsiev/environment.rb', line 21 def variables @bindings.keys end |