class Aggregate
Aggregate coverage totals.
Definitions
def initialize
Initialize empty aggregate statistics.
Implementation
def initialize
@count = 0
@executable_count = 0
@executed_count = 0
end
attr :count
Total number of files added.
Signature
-
returns
Integer The number of coverage objects added.
attr :executable_count
The number of lines which could have been executed.
Signature
-
returns
Integer The executable line count.
attr :executed_count
The number of lines that were executed.
Signature
-
returns
Integer The executed line count.
def as_json
A JSON-compatible representation of these aggregate statistics.
Signature
-
returns
Hash The aggregate count, line counts and percentage.
Implementation
def as_json
{
count: count,
executable_count: executable_count,
executed_count: executed_count,
percentage: percentage.to_f.round(2),
}
end
def to_json(options)
Convert these aggregate statistics to JSON.
Signature
-
parameter
optionsHash Options forwarded to
to_json.-
returns
String The JSON representation.
Implementation
def to_json(options)
as_json.to_json(options)
end
def <<(coverage)
Add coverage to these aggregate statistics.
Signature
-
parameter
coverageCovered::Coverage The coverage object to add.
Implementation
def << coverage
@count += 1
@executable_count += coverage.executable_count
@executed_count += coverage.executed_count
end