Returns the value of some variable.
a = 2 binding["a"] #=> 2
# File lib/core/facets/binding/op.rb, line 10 def []( x ) eval( x.to_s ) end
Set the value of a local variable.
binding["a"] = 4 a #=> 4
# File lib/core/facets/binding/op.rb, line 19 def []=( l, v ) eval( "lambda {|v| #{l} = v}").call( v ) end
Return the directory of the file in which the binding was created.
# File lib/core/facets/binding/caller.rb, line 27 def __DIR__ File.dirname(self.__FILE__) end
Returns file name in which the binding was created.
# File lib/core/facets/binding/caller.rb, line 21 def __FILE__ Kernel.eval("__FILE__", self) end
Return the line number on which the binding was created.
# File lib/core/facets/binding/caller.rb, line 15 def __LINE__ Kernel.eval("__LINE__", self) end
Retreive the current running method.
# File lib/core/facets/binding/caller.rb, line 39 def __callee__ Kernel.eval("__callee__", self) end
Retreive the current running method.
# File lib/core/facets/binding/caller.rb, line 33 def __method__ Kernel.eval("__method__", self) end
Returns the call stack, in array format.
# File lib/core/facets/kernel/call_stack.rb, line 50 def call_stack(level=1) eval( "callstack( #{level} )" ) end
Returns the call stack, same format as Kernel#caller()
# File lib/core/facets/binding/caller.rb, line 9 def caller( skip=0 ) eval("caller(#{skip})") end
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
Evaluate a Ruby source code string (or block) in the binding context.
# File lib/core/facets/binding/eval.rb, line 7 def eval(str) Kernel.eval(str, self) end
Returns the local variables defined in the binding context:
a = 1 b = 2 binding.local_variables #=> [:a, :b]
# File lib/core/facets/binding/local_variables.rb, line 12 def local_variables() eval("local_variables") end
Returns self of the binding context.
# File lib/core/facets/binding/self.rb, line 7 def self() @_self ||= eval("self") end