class Parslet::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

@api private

Public Class Methods

new(bindings) click to toggle source
# File lib/parslet/context.rb, line 15
def initialize(bindings)
  bindings.each do |key, value|
    singleton_class.send(:define_method, key) { value }
    instance_variable_set("@#{key}", value)
  end
end