Class: SimpleCov::SourceFile::Line
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/simplecov/source_file/line.rb |
Overview
Representation of a single line in a source file including this specific line’s source code, line_number and code coverage, with the coverage being either nil (coverage not applicable, e.g. comment line), 0 (line not covered) or >1 (the amount of times the line was executed)
Class Method Summary
- .new(src, line_number, coverage) ⇒ Line constructor
Instance Attribute Summary
-
#coverage
readonly
The coverage data for this line: either nil (never), 0 (missed) or >=1 (times covered).
-
#covered? ⇒ Boolean
readonly
Returns true if this is a line that has been covered.
-
#line
readonly
Alias for #line_number.
-
#line_number
(also: #line, #number)
readonly
The line number in the source file.
-
#missed? ⇒ Boolean
readonly
Returns true if this is a line that should have been covered, but was not.
-
#never? ⇒ Boolean
readonly
Returns true if this line is not relevant for coverage.
-
#number
readonly
Alias for #line_number.
-
#skipped
readonly
Whether this line was skipped.
-
#skipped? ⇒ Boolean
readonly
Returns true if this line was skipped, false otherwise.
-
#source
readonly
Alias for #src.
-
#src
(also: #source)
readonly
The source code for this line.
Instance Method Summary
Constructor Details
.new(src, line_number, coverage) ⇒ Line
# File 'lib/simplecov/source_file/line.rb', line 25
def initialize(src, line_number, coverage) raise ArgumentError, "Only String accepted for source" unless src.is_a?(String) raise ArgumentError, "Only Integer accepted for line_number" unless line_number.is_a?(Integer) raise ArgumentError, "Only Integer and nil accepted for coverage" unless coverage.is_a?(Integer) || coverage.nil? @src = src @line_number = line_number @coverage = coverage @skipped = false end
Instance Attribute Details
#coverage (readonly)
The coverage data for this line: either nil (never), 0 (missed) or >=1 (times covered)
# File 'lib/simplecov/source_file/line.rb', line 16
attr_reader :coverage
#covered? ⇒ Boolean
(readonly)
Returns true if this is a line that has been covered
#line (readonly)
Alias for #line_number.
# File 'lib/simplecov/source_file/line.rb', line 22
alias line line_number
#line_number (readonly) Also known as: #line, #number
The line number in the source file. Aliased as :line
, :number
# File 'lib/simplecov/source_file/line.rb', line 14
attr_reader :line_number
#missed? ⇒ Boolean
(readonly)
Returns true if this is a line that should have been covered, but was not
#never? ⇒ Boolean
(readonly)
Returns true if this line is not relevant for coverage
#number (readonly)
Alias for #line_number.
# File 'lib/simplecov/source_file/line.rb', line 23
alias number line_number
#skipped (readonly)
Whether this line was skipped
# File 'lib/simplecov/source_file/line.rb', line 18
attr_reader :skipped
#skipped? ⇒ Boolean
(readonly)
Returns true if this line was skipped, false otherwise. Lines are skipped if they are wrapped with
:nocov: comment lines.
# File 'lib/simplecov/source_file/line.rb', line 58
def skipped? skipped end
#source (readonly)
Alias for #src.
# File 'lib/simplecov/source_file/line.rb', line 21
alias source src
#src (readonly) Also known as: #source
The source code for this line. Aliased as :source
# File 'lib/simplecov/source_file/line.rb', line 12
attr_reader :src
Instance Method Details
#skipped!
Flags this line as skipped
# File 'lib/simplecov/source_file/line.rb', line 52
def skipped! @skipped = true end
#status
The status of this line - either covered, missed, skipped or never. Useful i.e. for direct use as a css class in report generation