Class Binding
In: lib/core/facets/kernel/callstack.rb
lib/core/facets/binding/opvars.rb
lib/core/facets/binding/defined.rb
lib/core/facets/binding/local_variables.rb
lib/core/facets/binding/self.rb
lib/core/facets/binding/eval.rb
lib/core/facets/binding/caller.rb
Parent: Object

Methods

[]   []=   __DIR__   __FILE__   __LINE__   __callee__   __method__   caller   callstack   defined?   eval   local_variables   self  

Public Instance methods

Returns the value of some variable.

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

[Source]

    # File lib/core/facets/binding/opvars.rb, line 10
10:   def []( x )
11:     eval( x.to_s )
12:   end

Set the value of a local variable.

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

[Source]

    # File lib/core/facets/binding/opvars.rb, line 19
19:   def []=( l, v )
20:     eval( "lambda {|v| #{l} = v}").call( v )
21:   end

Return the directory of the file.

[Source]

    # File lib/core/facets/binding/caller.rb, line 22
22:   def __DIR__
23:     eval("File.dirname(__FILE__)")
24:   end

Returns file name.

[Source]

    # File lib/core/facets/binding/caller.rb, line 17
17:   def __FILE__
18:     eval("__FILE__")
19:   end

Returns line number.

[Source]

    # File lib/core/facets/binding/caller.rb, line 12
12:   def __LINE__
13:     eval("__LINE__")
14:   end

Retreive the current running method.

  def tester; p called; end
  tester  #=> :tester

[Source]

    # File lib/core/facets/binding/caller.rb, line 31
31:   def __callee__
32:     name = /\`([^\']+)\'/.match(caller(1).first)[1]
33:     return name.to_sym
34:   end

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"

[Source]

    # File lib/core/facets/binding/caller.rb, line 43
43:   def __method__
44:     name = /\`([^\']+)\'/.match(caller(1).first)[1]
45:     return name
46:   end

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

[Source]

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

Returns the call stack, in array format.

[Source]

    # File lib/core/facets/kernel/callstack.rb, line 47
47:   def callstack(level=1)
48:     eval( "callstack( #{level} )" )
49:   end

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

[Source]

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

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

[Source]

    # File lib/core/facets/binding/eval.rb, line 7
 7:     def eval(str) #='', &blk )
 8:       #if block_given?
 9:       #  Kernel.eval( self, &blk )
10:       #elsif str
11:         Kernel.eval(str, self)
12:       #end
13:     end

Returns the local variables defined in the binding context

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

[Source]

    # File lib/core/facets/binding/local_variables.rb, line 10
10:   def local_variables()
11:     eval("local_variables")
12:   end

Returns self of the binding context.

[Source]

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

[Validate]