Class: Parslet::Transform::Context

### Home Classes Methods

### In Files

- lib/parslet/transform/context.rb

### Parent

BlankSlate

### Methods

- ::new
- #meta_def

### Files

- README

### Class/Module Index

Quicksearch

- Parslet
- Parslet::Atoms
- Parslet::Atoms::Alternative
- Parslet::Atoms::Base
- Parslet::Atoms::CanFlatten
- Parslet::Atoms::Capture
- Parslet::Atoms::Context
- Parslet::Atoms::DSL
- Parslet::Atoms::Dynamic
- Parslet::Atoms::Entity
- Parslet::Atoms::Lookahead
- Parslet::Atoms::Named
- Parslet::Atoms::Precedence
- Parslet::Atoms::Re
- Parslet::Atoms::Repetition
- Parslet::Atoms::Scope
- Parslet::Atoms::Sequence
- Parslet::Atoms::Str
- Parslet::Cause
- Parslet::ClassMethods
- Parslet::DelayedMatchConstructor
- Parslet::ErrorReporter
- Parslet::ErrorReporter::Deepest
- Parslet::ErrorReporter::Tree
- Parslet::Expression
- Parslet::Expression::Treetop
- Parslet::Expression::Treetop::Parser
- Parslet::Expression::Treetop::Transform
- Parslet::ParseFailed
- Parslet::Parser
- Parslet::Parser::PrettyPrinter
- Parslet::Parser::Visitors
- Parslet::Parser::Visitors::Citrus
- Parslet::Parser::Visitors::Treetop
- Parslet::Pattern
- Parslet::Pattern::SequenceBind
- Parslet::Pattern::SimpleBind
- Parslet::Pattern::SubtreeBind
- Parslet::Scope
- Parslet::Scope::Binding
- Parslet::Scope::NotFound
- Parslet::Slice
- Parslet::Source
- Parslet::Source::LineCache
- Parslet::Source::RangeSearch
- Parslet::Transform
- Parslet::Transform::Context

No matching classes.

# Parslet::Transform::Context

Provides a context for tree transformations to run in. The context allows accessing each of the bindings in the bindings hash as local method.

Example:

    ctx = Context.new(:a => :b)
    ctx.instance_eval do
      a # => :b
    end

### Public Class Methods

new(bindings) click to toggle source

    # File lib/parslet/transform/context.rb, line 26
    def initialize(bindings)
      bindings.each do |key, value|
        meta_def(key.to_sym) { value }
        instance_variable_set("@#{key}", value)
      end
    end

### Public Instance Methods

meta_def(name, &body) click to toggle source

    # File lib/parslet/transform/context.rb, line 20
    def meta_def(name, &body)
      metaclass = class <<self; self; end

      metaclass.send(:define_method, name, &body)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.