Class: SexpProcessor::Environment

### Home Classes Methods

### In Files

- lib/sexp_processor.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=
- #all
- #current
- #depth
- #scope

### Files

- History.txt
- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- SexpProcessor
- SexpProcessor::Environment
- CompositeSexpProcessor
- Examples
- MethodBasedSexpProcessor
- NotEmptyError
- Object
- ParseTreeTestCase
- Sexp
- SexpAny
- SexpInterpreter
- SexpMatchSpecial
- SexpMatchSpecials
- SexpProcessorError
- SexpTypeError
- Unique
- UnknownNodeError
- UnsupportedNodeError

No matching classes.

# SexpProcessor::Environment

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...

### Public Class Methods

new() click to toggle source

    # File lib/sexp_processor.rb, line 384
    def initialize
      @env = []
      @env.unshift({})
    end

### Public Instance Methods

[](name) click to toggle source

TODO: depth_of

    # File lib/sexp_processor.rb, line 399
    def [] name
      hash = @env.find { |closure| closure.has_key? name }
      hash[name] if hash
    end

[]=(name, val) click to toggle source

    # File lib/sexp_processor.rb, line 404
    def []= name, val
      hash = @env.find { |closure| closure.has_key? name } || current
      hash[name] = val
    end

all() click to toggle source

    # File lib/sexp_processor.rb, line 389
    def all
      @env.reverse.inject { |env, scope| env.merge scope }
    end

current() click to toggle source

    # File lib/sexp_processor.rb, line 409
    def current
      @env.first
    end

depth() click to toggle source

    # File lib/sexp_processor.rb, line 393
    def depth
      @env.length
    end

scope() click to toggle source

    # File lib/sexp_processor.rb, line 413
    def scope
      @env.unshift({})
      begin
        yield
      ensure
        @env.shift
        raise "You went too far unextending env" if @env.empty?
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.