Class: VariableScope
- Inherits:
-
Hash
- Object
- Hash
- VariableScope
- Defined in:
- lib/zombie_killer/variable_scope.rb
Overview
Tracks state for local variables visible at certain point. Keys are symbols, values are VariableState
Instance Method Summary collapse
-
#[](varname) ⇒ VariableState
State.
-
#[]=(varname, state) ⇒ Object
Set state for a variable.
-
#dup ⇒ Object
Deep copy the VariableState values.
-
#initialize ⇒ VariableScope
constructor
A new instance of VariableScope.
Constructor Details
#initialize ⇒ VariableScope
Returns a new instance of VariableScope.
9 10 11 12 13 |
# File 'lib/zombie_killer/variable_scope.rb', line 9 def initialize super do |hash, key| hash[key] = VariableState.new end end |
Instance Method Details
#[](varname) ⇒ VariableState
Returns state.
25 26 27 |
# File 'lib/zombie_killer/variable_scope.rb', line 25 def [](varname) super end |
#[]=(varname, state) ⇒ Object
Set state for a variable
30 31 32 |
# File 'lib/zombie_killer/variable_scope.rb', line 30 def []=(varname, state) super end |
#dup ⇒ Object
Deep copy the VariableState values
16 17 18 19 20 21 22 |
# File 'lib/zombie_killer/variable_scope.rb', line 16 def dup copy = self.class.new each do |k, v| copy[k] = v.dup end copy end |