Class: CoverageInfo
- Inherits:
-
Object
- Object
- CoverageInfo
- Defined in:
- lib/rcov/coverage_info.rb
Overview
Rcov::CoverageInfo is but a wrapper for an array, with some additional checks. It is returned by FileStatistics#coverage.
Instance Method Summary collapse
-
#[](line) ⇒ Object
Return the coverage status for the requested line.
-
#[]=(line, val) ⇒ Object
:nodoc:.
-
#initialize(coverage_array) ⇒ CoverageInfo
constructor
A new instance of CoverageInfo.
-
#method_missing(meth, *a, &b) ⇒ Object
:nodoc:.
-
#to_a ⇒ Object
Return an Array holding the code coverage information.
Constructor Details
#initialize(coverage_array) ⇒ CoverageInfo
Returns a new instance of CoverageInfo.
4 5 6 |
# File 'lib/rcov/coverage_info.rb', line 4 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:
33 34 35 |
# File 'lib/rcov/coverage_info.rb', line 33 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
16 17 18 |
# File 'lib/rcov/coverage_info.rb', line 16 def [](line) @cover[line] end |
#[]=(line, val) ⇒ Object
:nodoc:
20 21 22 23 24 25 26 |
# File 'lib/rcov/coverage_info.rb', line 20 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_a ⇒ Object
Return an Array holding the code coverage information.
29 30 31 |
# File 'lib/rcov/coverage_info.rb', line 29 def to_a @cover.clone end |