Class: Rcov::CallSiteAnalyzer::CallSite

Inherits:
Struct
  • Object
show all
Defined in:
lib/rcov.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

Instance Method Summary collapse

Instance Attribute Details

#backtraceObject

Returns the value of attribute backtrace

Returns:

  • (Object)

    the current value of backtrace



817
818
819
# File 'lib/rcov.rb', line 817

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.



848
849
850
851
# File 'lib/rcov.rb', line 848

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.



841
842
843
844
# File 'lib/rcov.rb', line 841

def calling_method(level = 0)
  stack_frame = backtrace[level]
  stack_frame ? stack_frame[1] : nil
end

#depthObject

The depth of a CallSite is the number of stack frames whose information is included in the CallSite object.



820
821
822
# File 'lib/rcov.rb', line 820

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).



826
827
828
829
# File 'lib/rcov.rb', line 826

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).



833
834
835
836
# File 'lib/rcov.rb', line 833

def line(level = 0)
  stack_frame = backtrace[level]
  stack_frame ? stack_frame[3] : nil
end