Class: SimpleCov::SourceFile::Method
- Inherits:
-
Object
- Object
- SimpleCov::SourceFile::Method
- Defined in:
- lib/simplecov/source_file/method.rb,
sig/simplecov.rbs
Overview
A single method detected in the coverage data.
Instance Attribute Summary collapse
-
#class_name ⇒ Module, String
readonly
A Module when the data comes straight from Coverage, a String after a JSON round-trip through a resultset.
-
#coverage ⇒ Integer
readonly
Returns the value of attribute coverage.
-
#end_col ⇒ Integer?
readonly
Returns the value of attribute end_col.
-
#end_line ⇒ Integer?
readonly
Returns the value of attribute end_line.
-
#method_name ⇒ Symbol, String
readonly
Returns the value of attribute method_name.
-
#source_file ⇒ SourceFile
readonly
Returns the value of attribute source_file.
-
#start_col ⇒ Integer?
readonly
Returns the value of attribute start_col.
-
#start_line ⇒ Integer?
readonly
Returns the value of attribute start_line.
Instance Method Summary collapse
- #covered? ⇒ Boolean
-
#initialize(source_file, info, coverage) ⇒ Method
constructor
info is the Coverage method key minus its class entry: [class_name, method_name, start_line, start_col, end_line, end_col].
-
#lines ⇒ Array[Line]
The source lines spanned by this method ([] when the location is unknown).
- #missed? ⇒ Boolean
-
#overlaps_with?(line_range) ⇒ Boolean
Whether this method's source range intersects the given inclusive line range.
-
#skipped! ⇒ void
Flag the method as skipped directly, without going through its lines.
- #skipped? ⇒ Boolean
- #to_s ⇒ String
Constructor Details
#initialize(source_file, info, coverage) ⇒ Method
info is the Coverage method key minus its class entry: [class_name, method_name, start_line, start_col, end_line, end_col].
1033 1034 1035 1036 1037 |
# File 'sig/simplecov.rbs', line 1033 def initialize(source_file, info, coverage) @source_file = source_file @class_name, @method_name, @start_line, @start_col, @end_line, @end_col = info @coverage = coverage end |
Instance Attribute Details
#class_name ⇒ Module, String (readonly)
A Module when the data comes straight from Coverage, a String after a JSON round-trip through a resultset.
1021 1022 1023 |
# File 'sig/simplecov.rbs', line 1021 def class_name @class_name end |
#coverage ⇒ Integer (readonly)
Returns the value of attribute coverage.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def coverage @coverage end |
#end_col ⇒ Integer? (readonly)
Returns the value of attribute end_col.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def end_col @end_col end |
#end_line ⇒ Integer? (readonly)
Returns the value of attribute end_line.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def end_line @end_line end |
#method_name ⇒ Symbol, String (readonly)
Returns the value of attribute method_name.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def method_name @method_name end |
#source_file ⇒ SourceFile (readonly)
Returns the value of attribute source_file.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def source_file @source_file end |
#start_col ⇒ Integer? (readonly)
Returns the value of attribute start_col.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def start_col @start_col end |
#start_line ⇒ Integer? (readonly)
Returns the value of attribute start_line.
8 9 10 |
# File 'lib/simplecov/source_file/method.rb', line 8 def start_line @start_line end |
Instance Method Details
#covered? ⇒ Boolean
17 18 19 |
# File 'lib/simplecov/source_file/method.rb', line 17 def covered? !skipped? && coverage.positive? end |
#lines ⇒ Array[Line]
The source lines spanned by this method ([] when the location is unknown).
1040 1041 1042 |
# File 'sig/simplecov.rbs', line 1040 def lines @lines ||= start_line && end_line ? source_file.lines[(start_line - 1)..(end_line - 1)] || [] : [] end |
#missed? ⇒ Boolean
32 33 34 |
# File 'lib/simplecov/source_file/method.rb', line 32 def missed? !skipped? && coverage.zero? end |
#overlaps_with?(line_range) ⇒ Boolean
Whether this method's source range intersects the given inclusive line range.
41 42 43 44 45 |
# File 'lib/simplecov/source_file/method.rb', line 41 def overlaps_with?(line_range) return false unless start_line && end_line start_line <= line_range.end && end_line >= line_range.begin end |
#skipped! ⇒ void
This method returns an undefined value.
Flag the method as skipped directly, without going through its lines.
28 29 30 |
# File 'lib/simplecov/source_file/method.rb', line 28 def skipped! @skipped = true end |
#skipped? ⇒ Boolean
21 22 23 24 25 |
# File 'lib/simplecov/source_file/method.rb', line 21 def skipped? return @skipped if defined?(@skipped) @skipped = lines.all?(&:skipped?) end |
#to_s ⇒ String
47 48 49 |
# File 'lib/simplecov/source_file/method.rb', line 47 def to_s "#{class_name}##{method_name}" end |