Class: SimpleCov::SourceFile::Branch
- Inherits:
-
Object
- Object
- SimpleCov::SourceFile::Branch
- Defined in:
- lib/simplecov/source_file/branch.rb,
sig/simplecov.rbs
Instance Attribute Summary collapse
-
#coverage ⇒ Integer
readonly
Returns the value of attribute coverage.
-
#end_line ⇒ Integer
readonly
Returns the value of attribute end_line.
-
#start_line ⇒ Integer
readonly
Returns the value of attribute start_line.
-
#type ⇒ Symbol
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #covered? ⇒ Boolean
-
#initialize(start_line:, end_line:, coverage:, inline:, type:) ⇒ Branch
constructor
A new instance of Branch.
- #inline? ⇒ Boolean
- #missed? ⇒ Boolean
- #overlaps_with?(line_range) ⇒ Boolean
- #report ⇒ [ Symbol, Integer ]
-
#report_line ⇒ Integer
Usually the line above the start of the branch, so that it shows up at the if/else.
- #skipped! ⇒ void
- #skipped? ⇒ Boolean
Constructor Details
#initialize(start_line:, end_line:, coverage:, inline:, type:) ⇒ Branch
Returns a new instance of Branch.
8 9 10 11 12 13 14 15 |
# File 'lib/simplecov/source_file/branch.rb', line 8 def initialize(start_line:, end_line:, coverage:, inline:, type:) @start_line = start_line @end_line = end_line @coverage = coverage @inline = inline @type = type @skipped = false end |
Instance Attribute Details
#coverage ⇒ Integer (readonly)
Returns the value of attribute coverage.
6 7 8 |
# File 'lib/simplecov/source_file/branch.rb', line 6 def coverage @coverage end |
#end_line ⇒ Integer (readonly)
Returns the value of attribute end_line.
6 7 8 |
# File 'lib/simplecov/source_file/branch.rb', line 6 def end_line @end_line end |
#start_line ⇒ Integer (readonly)
Returns the value of attribute start_line.
6 7 8 |
# File 'lib/simplecov/source_file/branch.rb', line 6 def start_line @start_line end |
#type ⇒ Symbol (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/simplecov/source_file/branch.rb', line 6 def type @type end |
Instance Method Details
#covered? ⇒ Boolean
21 22 23 |
# File 'lib/simplecov/source_file/branch.rb', line 21 def covered? !skipped? && coverage.positive? end |
#inline? ⇒ Boolean
17 18 19 |
# File 'lib/simplecov/source_file/branch.rb', line 17 def inline? @inline end |
#missed? ⇒ Boolean
25 26 27 |
# File 'lib/simplecov/source_file/branch.rb', line 25 def missed? !skipped? && coverage.zero? end |
#overlaps_with?(line_range) ⇒ Boolean
48 49 50 |
# File 'lib/simplecov/source_file/branch.rb', line 48 def overlaps_with?(line_range) start_line <= line_range.end && end_line >= line_range.begin end |
#report ⇒ [ Symbol, Integer ]
52 53 54 |
# File 'lib/simplecov/source_file/branch.rb', line 52 def report [type, coverage] end |
#report_line ⇒ Integer
Usually the line above the start of the branch, so that it shows up at the if/else. That highlights the condition, and makes it distinguishable when the first line of the branch is itself an inline branch.
32 33 34 35 36 37 38 |
# File 'lib/simplecov/source_file/branch.rb', line 32 def report_line if inline? start_line else start_line - 1 end end |
#skipped! ⇒ void
This method returns an undefined value.
40 41 42 |
# File 'lib/simplecov/source_file/branch.rb', line 40 def skipped! @skipped = true end |
#skipped? ⇒ Boolean
44 45 46 |
# File 'lib/simplecov/source_file/branch.rb', line 44 def skipped? @skipped end |