Class: Schaefer::Environment
- Inherits:
-
Object
- Object
- Schaefer::Environment
- Defined in:
- lib/schaefer/environment.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #define(name, value) ⇒ Object
- #find(name) ⇒ Object
-
#initialize(parent = nil) ⇒ Environment
constructor
A new instance of Environment.
- #removeDefinition(name) ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ Environment
Returns a new instance of Environment.
5 6 7 8 |
# File 'lib/schaefer/environment.rb', line 5 def initialize(parent = nil) @parent = parent @table = {} end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
3 4 5 |
# File 'lib/schaefer/environment.rb', line 3 def parent @parent end |
Instance Method Details
#define(name, value) ⇒ Object
16 17 18 |
# File 'lib/schaefer/environment.rb', line 16 def define(name, value) @table[name] = value end |
#find(name) ⇒ Object
10 11 12 13 14 |
# File 'lib/schaefer/environment.rb', line 10 def find(name) return @table[name] if @table.has_key?(name) return nil if @parent.nil? return @parent.find(name) end |
#removeDefinition(name) ⇒ Object
20 21 |
# File 'lib/schaefer/environment.rb', line 20 def removeDefinition(name) end |