Sha256: 39f91d82f90be8d5b85317dfe14f2dd8551759cab4f314dae27e271992f2b6dd
Contents?: true
Size: 959 Bytes
Versions: 5
Compression:
Stored size: 959 Bytes
Contents
require 'facets/binding/eval' require 'facets/binding/callstack' class Binding # Returns the call stack, same format as Kernel#caller() def caller( skip=0 ) eval("caller(#{skip})") end # Returns line number. def __LINE__ eval("__LINE__") end # Returns file name. def __FILE__ eval("__FILE__") end # Return the directory of the file. def __DIR__ eval("File.dirname(__FILE__)") end # Retreive the current running method. # # def tester; p called; end # tester #=> :tester # def __callee__ name = /\`([^\']+)\'/.match(caller(1).first)[1] return name.to_sym 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" # def __method__ name = /\`([^\']+)\'/.match(caller(1).first)[1] return name end end
Version data entries
5 entries across 5 versions & 1 rubygems