Class: Covered::Statistics::Aggregate
- Inherits:
-
Object
- Object
- Covered::Statistics::Aggregate
- Includes:
- Ratio
- Defined in:
- lib/covered/statistics.rb
Overview
Aggregate coverage totals.
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#executable_count ⇒ Object
readonly
The number of lines which could have been executed.
-
#executed_count ⇒ Object
readonly
The number of lines that were executed.
- #The total number of coverage instances added.(totalnumberofcoverageinstancesadded.) ⇒ Object readonly
Class Method Summary collapse
-
.for(coverages) ⇒ Object
Build aggregate statistics from coverage objects.
Instance Method Summary collapse
-
#<<(coverage) ⇒ Object
Add coverage to these aggregate statistics.
-
#as_json ⇒ Object
A JSON-compatible representation of these aggregate statistics.
-
#initialize ⇒ Aggregate
constructor
Initialize empty aggregate statistics.
-
#to_json(options) ⇒ Object
Convert these aggregate statistics to JSON.
Methods included from Ratio
#complete?, #percentage, #ratio
Constructor Details
#initialize ⇒ Aggregate
Initialize empty aggregate statistics.
43 44 45 46 47 |
# File 'lib/covered/statistics.rb', line 43 def initialize @count = 0 @executable_count = 0 @executed_count = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
50 51 52 |
# File 'lib/covered/statistics.rb', line 50 def count @count end |
#executable_count ⇒ Object (readonly)
The number of lines which could have been executed.
54 55 56 |
# File 'lib/covered/statistics.rb', line 54 def executable_count @executable_count end |
#executed_count ⇒ Object (readonly)
The number of lines that were executed.
58 59 60 |
# File 'lib/covered/statistics.rb', line 58 def executed_count @executed_count end |
#The total number of coverage instances added.(totalnumberofcoverageinstancesadded.) ⇒ Object (readonly)
50 |
# File 'lib/covered/statistics.rb', line 50 attr :count |
Class Method Details
.for(coverages) ⇒ Object
Build aggregate statistics from coverage objects.
34 35 36 37 38 39 40 |
# File 'lib/covered/statistics.rb', line 34 def self.for(coverages) self.new.tap do |aggregate| coverages.each do |coverage| aggregate << coverage end end end |
Instance Method Details
#<<(coverage) ⇒ Object
Add coverage to these aggregate statistics.
81 82 83 84 85 86 87 88 |
# File 'lib/covered/statistics.rb', line 81 def << coverage @count += 1 @executable_count += coverage.executable_count @executed_count += coverage.executed_count self end |
#as_json ⇒ Object
A JSON-compatible representation of these aggregate statistics.
62 63 64 65 66 67 68 69 |
# File 'lib/covered/statistics.rb', line 62 def as_json { count: count, executable_count: executable_count, executed_count: executed_count, percentage: percentage.to_f.round(2), } end |
#to_json(options) ⇒ Object
Convert these aggregate statistics to JSON.
74 75 76 |
# File 'lib/covered/statistics.rb', line 74 def to_json() as_json.to_json() end |