Class: Rcov::CallSiteAnalyzer::CallSite
- Inherits:
-
Struct
- Object
- Struct
- Rcov::CallSiteAnalyzer::CallSite
- Defined in:
- lib/rcov/call_site_analyzer.rb
Overview
Object representing a method call site. It corresponds to a part of the callstack starting from the context that called the method.
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
Instance Method Summary collapse
-
#calling_class(level = 0) ⇒ Object
Name of the class holding the method where the call originated.
-
#calling_method(level = 0) ⇒ Object
Name of the method where the call originated.
-
#depth ⇒ Object
The depth of a CallSite is the number of stack frames whose information is included in the CallSite object.
-
#file(level = 0) ⇒ Object
File where the method call originated.
-
#line(level = 0) ⇒ Object
Line where the method call originated.
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace
54 55 56 |
# File 'lib/rcov/call_site_analyzer.rb', line 54 def backtrace @backtrace end |
Instance Method Details
#calling_class(level = 0) ⇒ Object
Name of the class holding the method where the call originated. Might return nil
if it could not be determined.
85 86 87 88 |
# File 'lib/rcov/call_site_analyzer.rb', line 85 def calling_class(level = 0) stack_frame = backtrace[level] stack_frame ? stack_frame[0] : nil end |
#calling_method(level = 0) ⇒ Object
Name of the method where the call originated. Returns nil
if the call originated in toplevel
. Might return nil
if it could not be determined.
78 79 80 81 |
# File 'lib/rcov/call_site_analyzer.rb', line 78 def calling_method(level = 0) stack_frame = backtrace[level] stack_frame ? stack_frame[1] : nil end |
#depth ⇒ Object
The depth of a CallSite is the number of stack frames whose information is included in the CallSite object.
57 58 59 |
# File 'lib/rcov/call_site_analyzer.rb', line 57 def depth backtrace.size end |
#file(level = 0) ⇒ Object
File where the method call originated. Might return nil
or “” if it is not meaningful (C extensions, etc).
63 64 65 66 |
# File 'lib/rcov/call_site_analyzer.rb', line 63 def file(level = 0) stack_frame = backtrace[level] stack_frame ? stack_frame[2] : nil end |
#line(level = 0) ⇒ Object
Line where the method call originated. Might return nil
or 0 if it is not meaningful (C extensions, etc).
70 71 72 73 |
# File 'lib/rcov/call_site_analyzer.rb', line 70 def line(level = 0) stack_frame = backtrace[level] stack_frame ? stack_frame[3] : nil end |