Class: RubyParserStuff::Environment

### Home Classes Methods

### In Files

- lib/ruby_parser_extras.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=
- #all
- #current
- #dynamic
- #dynamic?
- #extend
- #reset
- #unextend
- #use
- #used?

### Files

- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- RubyParserStuff
- RubyParserStuff::Environment
- RubyParserStuff::Keyword
- RubyParserStuff::Keyword::KWtable
- RubyParserStuff::Ruby18Parser
- RubyParserStuff::Ruby19Parser
- RubyParserStuff::Ruby20Parser
- RubyParserStuff::RubyParser
- RubyParserStuff::RubyParser::SyntaxError
- RubyParserStuff::Sexp
- RubyParserStuff::StackState
- RubyParserStuff::String
- RPStringScanner
- Ruby18Parser
- Ruby19Parser
- Ruby20Parser
- RubyLexer
- RubyParserGauntlet

No matching classes.

# RubyParserStuff::Environment

### Attributes

dyn[R]
env[R]

### Public Class Methods

new(dyn = false) click to toggle source

    # File lib/ruby_parser_extras.rb, line 1253
    def initialize dyn = false
      @dyn = []
      @env = []
      @use = []
      self.reset
    end

### Public Instance Methods

[](k) click to toggle source

    # File lib/ruby_parser_extras.rb, line 1220
    def [] k
      self.all[k]
    end

[]=(k, v) click to toggle source

    # File lib/ruby_parser_extras.rb, line 1224
    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 1229
    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 1234
    def current
      @env.first
    end

dynamic() click to toggle source

    # File lib/ruby_parser_extras.rb, line 1238
    def dynamic
      idx = @dyn.index false
      @env[0...idx].reverse.inject { |env, scope| env.merge scope } || {}
    end

dynamic?() click to toggle source

    # File lib/ruby_parser_extras.rb, line 1243
    def dynamic?
      @dyn[0] != false
    end

extend(dyn = false) click to toggle source

    # File lib/ruby_parser_extras.rb, line 1247
    def extend dyn = false
      @dyn.unshift dyn
      @env.unshift({})
      @use.unshift({})
    end

reset() click to toggle source

    # File lib/ruby_parser_extras.rb, line 1260
    def reset
      @dyn.clear
      @env.clear
      @use.clear
      self.extend
    end

unextend() click to toggle source

    # File lib/ruby_parser_extras.rb, line 1267
    def unextend
      @dyn.shift
      @env.shift
      @use.shift
      raise "You went too far unextending env" if @env.empty?
    end

use(id) click to toggle source

    # File lib/ruby_parser_extras.rb, line 1274
    def use id
      @env.each_with_index do |env, i|
        if env[id] then
          @use[i][id] = true
        end
      end
    end

used?(id) click to toggle source

    # File lib/ruby_parser_extras.rb, line 1282
    def used? id
      idx = @dyn.index false # REFACTOR
      u = @use[0...idx].reverse.inject { |env, scope| env.merge scope } || {}
      u[id]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.