class RubyParserStuff::Environment

Attributes

dyn[R]
env[R]

Public Class Methods

new(dyn = false) click to toggle source
# File lib/ruby_parser_extras.rb, line 1305
def initialize dyn = false
  @dyn = []
  @env = []
  self.reset
end

Public Instance Methods

[](k) click to toggle source
# File lib/ruby_parser_extras.rb, line 1282
def [] k
  self.all[k]
end
[]=(k, v) click to toggle source
# File lib/ruby_parser_extras.rb, line 1286
def []= k, v
  raise "no" if v == true
  self.current[k] = v
end
all() click to toggle source
# File lib/ruby_parser_extras.rb, line 1291
def all
  idx = @dyn.index(false) || 0
  @env[0..idx].reverse.inject { |env, scope| env.merge scope }
end
current() click to toggle source
# File lib/ruby_parser_extras.rb, line 1296
def current
  @env.first
end
extend(dyn = false) click to toggle source
# File lib/ruby_parser_extras.rb, line 1300
def extend dyn = false
  @dyn.unshift dyn
  @env.unshift({})
end
reset() click to toggle source
# File lib/ruby_parser_extras.rb, line 1311
def reset
  @dyn.clear
  @env.clear
  self.extend
end
unextend() click to toggle source
# File lib/ruby_parser_extras.rb, line 1317
def unextend
  @dyn.shift
  @env.shift
  raise "You went too far unextending env" if @env.empty?
end