Class: Coco::Summary
- Inherits:
-
Object
- Object
- Coco::Summary
- Defined in:
- lib/coco/cover/summary.rb
Overview
A very brief summary of the coverage result.
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#uncovered_count ⇒ Object
readonly
Returns the value of attribute uncovered_count.
Instance Method Summary collapse
-
#average ⇒ Object
Public: Computes the average coverage rate.
-
#initialize(result, uncovered) ⇒ Summary
constructor
A new instance of Summary.
- #to_s ⇒ Object
Constructor Details
#initialize(result, uncovered) ⇒ Summary
Returns a new instance of Summary.
8 9 10 11 12 |
# File 'lib/coco/cover/summary.rb', line 8 def initialize(result, uncovered) @uncovered_count = uncovered.size @coverable_files = result.coverable_files @count = @coverable_files.size + @uncovered_count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
6 7 8 |
# File 'lib/coco/cover/summary.rb', line 6 def count @count end |
#uncovered_count ⇒ Object (readonly)
Returns the value of attribute uncovered_count.
6 7 8 |
# File 'lib/coco/cover/summary.rb', line 6 def uncovered_count @uncovered_count end |
Instance Method Details
#average ⇒ Object
Public: Computes the average coverage rate. The formula is simple:
N = number of files f = a file average = sum(f_i%) / N
In words: Take the sum of the coverage’s percentage of all files and divide this sum by the number of files.
Returns the Float average rate of coverage.
30 31 32 |
# File 'lib/coco/cover/summary.rb', line 30 def average files_present? ? sum / count : 0 end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/coco/cover/summary.rb', line 14 def to_s "Cover #{'%.2f' % average}% | #{uncovered_count} uncovered | #{count} files" end |