I really hate this here, but I hate subdirs in my lib dir more… I guess it is kinda like shaving… I’ll split this out when it itches too much…
# File lib/sexp_processor.rb, line 379 def initialize @env = [] @env.unshift({}) end
TODO: depth_of
# File lib/sexp_processor.rb, line 394 def [] name hash = @env.find { |closure| closure.has_key? name } hash[name] if hash end
# File lib/sexp_processor.rb, line 399 def []= name, val hash = @env.find { |closure| closure.has_key? name } || current hash[name] = val end
# File lib/sexp_processor.rb, line 384 def all @env.reverse.inject { |env, scope| env.merge scope } end
# File lib/sexp_processor.rb, line 404 def current @env.first end
# File lib/sexp_processor.rb, line 388 def depth @env.length end
# File lib/sexp_processor.rb, line 408 def scope @env.unshift({}) begin yield ensure @env.shift raise "You went too far unextending env" if @env.empty? end end