Class: SimpleCov::SourceFile::Line
- Inherits:
-
Object
- Object
- SimpleCov::SourceFile::Line
- Defined in:
- lib/simplecov/source_file/line.rb,
sig/simplecov.rbs
Instance Attribute Summary collapse
-
#coverage ⇒ Integer?
readonly
Returns the value of attribute coverage.
-
#line_number ⇒ Integer
(also: #line, #number)
readonly
Returns the value of attribute line_number.
-
#skipped ⇒ Boolean
readonly
Returns the value of attribute skipped.
-
#src ⇒ String
(also: #source)
readonly
Returns the value of attribute src.
Instance Method Summary collapse
- #covered? ⇒ Boolean
-
#initialize(src, line_number, coverage) ⇒ Line
constructor
A new instance of Line.
-
#missed? ⇒ Boolean
Asking
covered?rather than reading the count a second time keeps the two answers from ever disagreeing, andnever?ahead of it is what keeps a line with no coverage at all out of the missed column. - #never? ⇒ Boolean
- #skipped! ⇒ void
- #skipped? ⇒ Boolean
- #status ⇒ String
Constructor Details
#initialize(src, line_number, coverage) ⇒ Line
Returns a new instance of Line.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/simplecov/source_file/line.rb', line 12 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) unless coverage.is_a?(Integer) || coverage.nil? raise ArgumentError, "Only Integer and nil accepted for coverage" end @src = src @line_number = line_number @coverage = coverage @skipped = false end |
Instance Attribute Details
#coverage ⇒ Integer? (readonly)
Returns the value of attribute coverage.
6 7 8 |
# File 'lib/simplecov/source_file/line.rb', line 6 def coverage @coverage end |
#line_number ⇒ Integer (readonly) Also known as: line, number
Returns the value of attribute line_number.
6 7 8 |
# File 'lib/simplecov/source_file/line.rb', line 6 def line_number @line_number end |
#skipped ⇒ Boolean (readonly)
Returns the value of attribute skipped.
6 7 8 |
# File 'lib/simplecov/source_file/line.rb', line 6 def skipped @skipped end |
#src ⇒ String (readonly) Also known as: source
Returns the value of attribute src.
6 7 8 |
# File 'lib/simplecov/source_file/line.rb', line 6 def src @src end |
Instance Method Details
#covered? ⇒ Boolean
32 33 34 |
# File 'lib/simplecov/source_file/line.rb', line 32 def covered? !skipped? && coverage.to_i.positive? end |
#missed? ⇒ Boolean
Asking covered? rather than reading the count a second time keeps the two
answers from ever disagreeing, and never? ahead of it is what keeps a
line with no coverage at all out of the missed column.
28 29 30 |
# File 'lib/simplecov/source_file/line.rb', line 28 def missed? !never? && !skipped? && !covered? end |
#never? ⇒ Boolean
36 37 38 |
# File 'lib/simplecov/source_file/line.rb', line 36 def never? !skipped? && coverage.nil? end |
#skipped! ⇒ void
This method returns an undefined value.
40 41 42 |
# File 'lib/simplecov/source_file/line.rb', line 40 def skipped! @skipped = true end |
#skipped? ⇒ Boolean
44 45 46 |
# File 'lib/simplecov/source_file/line.rb', line 44 def skipped? skipped end |
#status ⇒ String
48 49 50 51 52 53 54 |
# File 'lib/simplecov/source_file/line.rb', line 48 def status return "skipped" if skipped? return "never" if never? return "missed" if missed? "covered" end |