class Binding

Public Instance Methods

[]( x ) click to toggle source

Returns the value of some variable.

a = 2
binding["a"]  #=> 2
# File lib/core/facets/binding/opvars.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
# File lib/core/facets/binding/opvars.rb, line 19
def []=( l, v )
  eval( "lambda {|v| #{l} = v}").call( v )
end
__DIR__() click to toggle source

Return the directory of the file.

# File lib/core/facets/binding/caller.rb, line 22
def __DIR__
  eval("File.dirname(__FILE__)")
end
__FILE__() click to toggle source

Returns file name.

# File lib/core/facets/binding/caller.rb, line 17
def __FILE__
  eval("__FILE__")
end
__LINE__() click to toggle source

Returns line number.

# File lib/core/facets/binding/caller.rb, line 12
def __LINE__
  eval("__LINE__")
end
__callee__() click to toggle source

Retreive the current running method.

def tester; p called; end
tester  #=> :tester
# File lib/core/facets/binding/caller.rb, line 31
def __callee__
  eval('__callee__')
end
__method__() click to toggle source

There is a lot of debate on what to call this. method_name differs from called only by the fact that it returns a string, rather then a symbol.

def tester; p methodname; end
tester  #=> "tester"
# File lib/core/facets/binding/caller.rb, line 42
def __method__
  eval('__method__')
end
caller( skip=0 ) click to toggle source

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

# File lib/core/facets/binding/caller.rb, line 7
def caller( skip=0 )
  eval("caller(#{skip})")
end
callstack(level=1) click to toggle source

Returns the call stack, in array format.

# File lib/core/facets/kernel/callstack.rb, line 47
def callstack(level=1)
  eval( "callstack( #{level} )" )
end
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/core/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/core/facets/binding/eval.rb, line 7
def eval(str) #='', &blk )
  #if block_given?
  #  Kernel.eval( self, &blk )
  #elsif str
    Kernel.eval(str, self)
  #end
end
local_variables() click to toggle source

Returns the local variables defined in the binding context

a = 2
binding.local_variables  #=> ["a"]
# File lib/core/facets/binding/local_variables.rb, line 10
def local_variables()
  eval("local_variables")
end
self() click to toggle source

Returns self of the binding context.

# File lib/core/facets/binding/self.rb, line 7
def self()
  @_self ||= eval("self")
end