Class: Rcov::CoverageInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/rcov.rb

Overview

checks. It is returned by FileStatistics#coverage.

Instance Method Summary collapse

Constructor Details

#initialize(coverage_array) ⇒ CoverageInfo

Returns a new instance of CoverageInfo.



34
35
36
# File 'lib/rcov.rb', line 34

def initialize(coverage_array)
  @cover = coverage_array.clone
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *a, &b) ⇒ Object

:nodoc:



63
64
65
# File 'lib/rcov.rb', line 63

def method_missing(meth, *a, &b) # :nodoc:
  @cover.send(meth, *a, &b)
end

Instance Method Details

#[](line) ⇒ Object

Return the coverage status for the requested line. There are four possible return values:

  • nil if there’s no information for the requested line (i.e. it doesn’t exist)

  • true if the line was reported by Ruby as executed

  • :inferred if rcov inferred it was executed, despite not being reported by Ruby.

  • false otherwise, i.e. if it was not reported by Ruby and rcov’s heuristics indicated that it was not executed



46
47
48
# File 'lib/rcov.rb', line 46

def [](line)
  @cover[line]
end

#[]=(line, val) ⇒ Object

:nodoc:



50
51
52
53
54
55
56
# File 'lib/rcov.rb', line 50

def []=(line, val) # :nodoc:
  unless [true, false, :inferred].include? val
    raise RuntimeError, "What does #{val} mean?" 
  end
  return if line < 0 || line >= @cover.size
  @cover[line] = val
end

#to_aObject

Return an Array holding the code coverage information.



59
60
61
# File 'lib/rcov.rb', line 59

def to_a
  @cover.clone
end