Class: Fluid::Environment
- Inherits:
-
Hash
- Object
- Hash
- Fluid::Environment
- Defined in:
- lib/fluid.rb
Overview
An environment holds variable->value bindings. Each variable name is an entry in a hash table. It is associated with a stack of values. Environments are manipulated by objects of class Var.
Instance Method Summary collapse
-
#create(var_name) ⇒ Object
:nodoc:.
- #destroy(var_name) ⇒ Object
- #get(var_name) ⇒ Object
- #has?(var_name) ⇒ Boolean
- #pop_binding(var_name) ⇒ Object
- #push_binding(var_name, var_value) ⇒ Object
- #set(var_name, value) ⇒ Object
- #unbound?(var_name) ⇒ Boolean
Instance Method Details
#create(var_name) ⇒ Object
:nodoc:
15 |
# File 'lib/fluid.rb', line 15 def create(var_name) self[var_name] = []; end |
#destroy(var_name) ⇒ Object
16 |
# File 'lib/fluid.rb', line 16 def destroy(var_name) delete(var_name); end |
#get(var_name) ⇒ Object
20 |
# File 'lib/fluid.rb', line 20 def get(var_name) self[var_name][-1]; end |
#has?(var_name) ⇒ Boolean
17 |
# File 'lib/fluid.rb', line 17 def has?(var_name) has_key?(var_name); end |
#pop_binding(var_name) ⇒ Object
22 |
# File 'lib/fluid.rb', line 22 def pop_binding(var_name) self[var_name].pop; end |
#push_binding(var_name, var_value) ⇒ Object
21 |
# File 'lib/fluid.rb', line 21 def push_binding(var_name, var_value) self[var_name].push(var_value); end |
#set(var_name, value) ⇒ Object
19 |
# File 'lib/fluid.rb', line 19 def set(var_name, value) self[var_name][-1] = value; end |
#unbound?(var_name) ⇒ Boolean
18 |
# File 'lib/fluid.rb', line 18 def unbound?(var_name) self[var_name] == []; end |