Class: VariableScope

Inherits:
Hash
  • Object
show all
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

Constructor Details

#initializeVariableScope

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.

Returns:



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

#dupObject

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