Class: SimpleCov::SourceFile::Branch
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/simplecov/source_file/branch.rb | 
Overview
Representing single branch that has been detected in coverage report. Give us support methods that handle needed calculations.
Class Method Summary
Instance Attribute Summary
- #coverage readonly
- 
    
      #covered?  ⇒ Boolean 
    
    readonly
    Return true if there is relevant count defined > 0. 
- #end_line readonly
- #inline? ⇒ Boolean readonly
- 
    
      #missed?  ⇒ Boolean 
    
    readonly
    Check if branch missed or not. 
- 
    
      #skipped?  ⇒ Boolean 
    
    readonly
    Returns true if the branch was marked skipped by virtue of nocov comments. 
- #start_line readonly
- #type readonly
Instance Method Summary
- #overlaps_with?(line_range) ⇒ Boolean
- 
    
      #report  ⇒ Array 
    
    Return array with coverage count and badge. 
- 
    
      #report_line  
    
    The line on which we want to report the coverage. 
- 
    
      #skipped!  
    
    Flags the branch as skipped. 
Constructor Details
    .new(start_line:, end_line:, coverage:, inline:, type:)  ⇒ Branch 
  
# File 'lib/simplecov/source_file/branch.rb', line 12
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 (readonly)
[ GitHub ]# File 'lib/simplecov/source_file/branch.rb', line 9
attr_reader :start_line, :end_line, :coverage, :type
    #covered?  ⇒ Boolean  (readonly)
  
Return true if there is relevant count defined > 0
#end_line (readonly)
[ GitHub ]# File 'lib/simplecov/source_file/branch.rb', line 9
attr_reader :start_line, :end_line, :coverage, :type
    #inline?  ⇒ Boolean  (readonly)
  
  [ GitHub ]
# File 'lib/simplecov/source_file/branch.rb', line 22
def inline? @inline end
    #missed?  ⇒ Boolean  (readonly)
  
Check if branch missed or not
    #skipped?  ⇒ Boolean  (readonly)
  
Returns true if the branch was marked skipped by virtue of nocov comments.
# File 'lib/simplecov/source_file/branch.rb', line 66
def skipped? @skipped end
#start_line (readonly)
[ GitHub ]#type (readonly)
[ GitHub ]# File 'lib/simplecov/source_file/branch.rb', line 9
attr_reader :start_line, :end_line, :coverage, :type
Instance Method Details
    #overlaps_with?(line_range)  ⇒ Boolean 
  
# File 'lib/simplecov/source_file/branch.rb', line 70
def overlaps_with?(line_range) start_line <= line_range.end && end_line >= line_range.begin end
    #report  ⇒ Array 
  
Return array with coverage count and badge
#report_line
The line on which we want to report the coverage
Usually we choose the line above the start of the branch (so that it shows up at if/else) because that
- 
highlights the condition 
- 
makes it distinguishable if the first line of the branch is an inline branch (see the nested_branches fixture) 
# File 'lib/simplecov/source_file/branch.rb', line 52
def report_line if inline? start_line else start_line - 1 end end
#skipped!
Flags the branch as skipped
# File 'lib/simplecov/source_file/branch.rb', line 61
def skipped! @skipped = true end