hacks/call_stack |
This is a hack for accessing the call stack. It uses set_trace_func, so using this hack may degrade performance. The result will be a global variable $call_stack, which is an array containing information about the caller. Each element of the array is itself an array containing the same information as would be returned by set_trace_func.
TODO: I need some good tests for this.
Eg.:
def foo; eval("x = 42", $call_stack[1][4]); end def bar; foo; end x = nil bar puts x
Public Methods |
Return the file of the caller
level | the level of the caller you want to query |
---|
Return the line of the caller
level | the level of the caller you want to query |
---|
Return the function the caller was in
level | the level of the caller you want to query |
---|
Return the caller's binding
level | the level of the caller who's binding you want |
---|
Return the class of the caller
level | the level of the caller who's class you want |
---|
Return the object ("self") of the caller
level | the level of the caller who's "self" you want |
---|