### Home Classes Methods

### In Files

- lib/facets/binding/defined.rb
- lib/facets/binding/with.rb
- lib/facets/binding/local_variables.rb
- lib/facets/binding/caller.rb
- lib/facets/binding/op_get.rb
- lib/facets/binding/self.rb
- lib/facets/binding/eval.rb
- lib/facets/kernel/call_stack.rb

### Parent

Object

### Methods

- #[]
- #[]=
- #__DIR__
- #__FILE__
- #__LINE__
- #__callee__
- #__method__
- #call_stack
- #caller
- #callstack
- #defined?
- #eval
- #local_variables
- #self
- #with

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Lazy
- Lazy::Future
- Lazy::Promise
- Lazy::Promise::DIVERGES
- Lazy::PromiseSafe
- Enumerable
- Enumerable::Recursor
- Method
- Method::Composition
- Module
- Module::InstanceFunction
- Array
- Binding
- Class
- Comparable
- Denumerable
- Denumerator
- Dir
- Enumerator
- Exception
- Facets
- FalseClass
- File
- FileTest
- Fixnum
- Float
- Functor
- Hash
- Indexable
- Instance
- Integer
- Kernel
- MatchData
- NA
- NilClass
- Numeric
- Object
- ObjectSpace
- Proc
- Process
- Range
- Regexp
- String
- Struct
- Symbol
- Time
- TrueClass
- UnboundMethod

No matching classes.

# Binding

### Public Instance Methods

[]( x ) click to toggle source

Returns the value of some variable.

    a = 2
    binding["a"]  #=> 2

    # File lib/facets/binding/op_get.rb, line 10
    def []( x )
      eval( x.to_s )
    end

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

Set the value of a local variable.

    binding["a"] = 4
    a  #=> 4

@deprecated No longer wortks in Ruby 1.9+.

@see Binding#with for an alternative.

    # File lib/facets/binding/op_get.rb, line 22
    def []=( l, v )
      eval( "lambda {|v| #{l} = v}").call( v )
    end

__DIR__() click to toggle source

Return the directory of the file in which the binding was created.

    # File lib/facets/binding/caller.rb, line 27
    def __DIR__
      File.dirname(self.__FILE__)
    end

__FILE__() click to toggle source

Returns file name in which the binding was created.

    # File lib/facets/binding/caller.rb, line 21
    def __FILE__
      Kernel.eval("__FILE__", self)
    end

__LINE__() click to toggle source

Return the line number on which the binding was created.

    # File lib/facets/binding/caller.rb, line 15
    def __LINE__
      Kernel.eval("__LINE__", self)
    end

__callee__() click to toggle source

Retreive the current running method.

    # File lib/facets/binding/caller.rb, line 39
    def __callee__
      Kernel.eval("__callee__", self)
    end

__method__() click to toggle source

Retreive the current running method.

    # File lib/facets/binding/caller.rb, line 33
    def __method__
      Kernel.eval("__method__", self)
    end

call_stack(level=1) click to toggle source

Returns the call stack, in array format.

    # File lib/facets/kernel/call_stack.rb, line 50
    def call_stack(level=1)
      eval( "callstack( #{level} )" )
    end

Also aliased as: callstack
caller( skip=0 ) click to toggle source

Returns the call stack, same format as Kernel#caller()

    # File lib/facets/binding/caller.rb, line 9
    def caller( skip=0 )
      eval("caller(#{skip})")
    end

callstack(level=1) click to toggle source
Alias for: call_stack
defined?(x) click to toggle source

Returns the nature of something within the context of the binding. Returns nil if that thing is not defined.

    # File lib/facets/binding/defined.rb, line 7
    def defined?(x)
      eval("defined? #{x}")
    end

eval(str) click to toggle source

Evaluate a Ruby source code string (or block) in the binding context.

    # File lib/facets/binding/eval.rb, line 7
    def eval(str)
      Kernel.eval(str, self)
    end

local_variables() click to toggle source

Returns the local variables defined in the binding context:

    a = 1
    b = 2

    binding.local_variables  #=> [:a, :b]

TODO: Rename this to prevent name clash?

    # File lib/facets/binding/local_variables.rb, line 13
    def local_variables()
      eval("local_variables")
    end

self() click to toggle source

Returns self of the binding's context.

    # File lib/facets/binding/self.rb, line 10
    def self
      eval('self')
    end

with(_local_variables, &_yields) click to toggle source

Returns a new binding with local varaibles set.

CREDIT: Trans

    # File lib/facets/binding/with.rb, line 7
    def with(_local_variables, &_yields)
      eval("lambda{ |#{_local_variables.keys.join(',')},&yields| binding }").call(*_local_variables.values, &_yields)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.