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.
11 12 13 14 15 |
# File 'lib/zombie_killer/variable_scope.rb', line 11 def initialize super do |hash, key| hash[key] = VariableState.new end end |
Instance Method Details
#[](varname) ⇒ VariableState
Returns state.
27 28 29 |
# File 'lib/zombie_killer/variable_scope.rb', line 27 def [](varname) super end |
#[]=(varname, state) ⇒ Object
Set state for a variable
32 33 34 |
# File 'lib/zombie_killer/variable_scope.rb', line 32 def []=(varname, state) super end |
#dup ⇒ Object
Deep copy the VariableState values
18 19 20 21 22 23 24 |
# File 'lib/zombie_killer/variable_scope.rb', line 18 def dup copy = self.class.new each do |k, v| copy[k] = v.dup end copy end |