Class: SimpleCov::SourceFile::Method
- Inherits:
-
Object
- Object
- SimpleCov::SourceFile::Method
- Defined in:
- lib/simplecov/source_file/method.rb,
sig/simplecov.rbs
Instance Attribute Summary collapse
-
#class_name ⇒ Module, String
readonly
Returns the value of attribute class_name.
-
#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
A new instance of Method.
- #lines ⇒ Array[Line]
- #missed? ⇒ Boolean
- #overlaps_with?(line_range) ⇒ Boolean
- #skipped! ⇒ void
-
#skipped? ⇒ Boolean
Criterion-level skips (nocov chunks,
# simplecov:disable/# simplecov:disable methodregions) arrive viaskipped!from MethodBuilder. - #to_s ⇒ String
Constructor Details
#initialize(source_file, info, coverage) ⇒ Method
Returns a new instance of Method.
9 10 11 12 13 |
# File 'lib/simplecov/source_file/method.rb', line 9 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)
Returns the value of attribute class_name.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def class_name @class_name end |
#coverage ⇒ Integer (readonly)
Returns the value of attribute coverage.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def coverage @coverage end |
#end_col ⇒ Integer? (readonly)
Returns the value of attribute end_col.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def end_col @end_col end |
#end_line ⇒ Integer? (readonly)
Returns the value of attribute end_line.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def end_line @end_line end |
#method_name ⇒ Symbol, String (readonly)
Returns the value of attribute method_name.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def method_name @method_name end |
#source_file ⇒ SourceFile (readonly)
Returns the value of attribute source_file.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def source_file @source_file end |
#start_col ⇒ Integer? (readonly)
Returns the value of attribute start_col.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def start_col @start_col end |
#start_line ⇒ Integer? (readonly)
Returns the value of attribute start_line.
6 7 8 |
# File 'lib/simplecov/source_file/method.rb', line 6 def start_line @start_line end |
Instance Method Details
#covered? ⇒ Boolean
15 16 17 |
# File 'lib/simplecov/source_file/method.rb', line 15 def covered? !skipped? && coverage.positive? end |
#lines ⇒ Array[Line]
39 40 41 |
# File 'lib/simplecov/source_file/method.rb', line 39 def lines @lines ||= (start_line && end_line) ? source_file.lines[(start_line - 1)..(end_line - 1)] || [] : [] end |
#missed? ⇒ Boolean
35 36 37 |
# File 'lib/simplecov/source_file/method.rb', line 35 def missed? !skipped? && coverage.zero? end |
#overlaps_with?(line_range) ⇒ Boolean
43 44 45 46 47 |
# File 'lib/simplecov/source_file/method.rb', line 43 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.
31 32 33 |
# File 'lib/simplecov/source_file/method.rb', line 31 def skipped! @skipped = true end |
#skipped? ⇒ Boolean
Criterion-level skips (nocov chunks, # simplecov:disable /
# simplecov:disable method regions) arrive via skipped! from
MethodBuilder. Deliberately NOT derived from the lines' skip
state: a line-only directive around a def must not remove the
method from method totals. Without line info there is nothing to
report against, so such a method stays skipped.
25 26 27 28 29 |
# File 'lib/simplecov/source_file/method.rb', line 25 def skipped? return @skipped if instance_variable_defined?(:@skipped) @skipped = lines.empty? end |
#to_s ⇒ String
49 50 51 |
# File 'lib/simplecov/source_file/method.rb', line 49 def to_s "#{class_name}##{method_name}" end |