class VariableScopeStack

A stack of VariableScope

Public Class Methods

new() click to toggle source
# File lib/zombie_killer/variable_scope.rb, line 39
def initialize
  outer_scope = VariableScope.new
  @stack = [outer_scope]
end

Public Instance Methods

innermost() click to toggle source

The innermost, or current VariableScope

# File lib/zombie_killer/variable_scope.rb, line 45
def innermost
  @stack.last
end
with_copy(&block) click to toggle source

Run block using a copy of the innermost scope @return the scope as the block left it, popped from the stack

# File lib/zombie_killer/variable_scope.rb, line 59
def with_copy(&block)
  @stack.push innermost.dup
  block.call
  @stack.pop
end
with_new(&block) click to toggle source

Run block using a new clean scope @return the scope as the block left it, popped from the stack

# File lib/zombie_killer/variable_scope.rb, line 51
def with_new(&block)
  @stack.push VariableScope.new
  block.call
  @stack.pop
end