Class: Covered::Statistics::Aggregate

Inherits:
Object
  • Object
show all
Includes:
Ratio
Defined in:
lib/covered/statistics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ratio

#complete?, #percentage, #ratio

Constructor Details

#initializeAggregate



25
26
27
28
29
# File 'lib/covered/statistics.rb', line 25

def initialize
  @count = 0
  @executable_count = 0
  @executed_count = 0
end

Instance Attribute Details

#countObject (readonly)

Total number of files added.



32
33
34
# File 'lib/covered/statistics.rb', line 32

def count
  @count
end

#executable_countObject (readonly)

The number of lines which could have been executed.



35
36
37
# File 'lib/covered/statistics.rb', line 35

def executable_count
  @executable_count
end

#executed_countObject (readonly)

The number of lines that were executed.



38
39
40
# File 'lib/covered/statistics.rb', line 38

def executed_count
  @executed_count
end

Instance Method Details

#<<(coverage) ⇒ Object



53
54
55
56
57
58
# File 'lib/covered/statistics.rb', line 53

def << coverage
  @count += 1
  
  @executable_count += coverage.executable_count
  @executed_count += coverage.executed_count
end

#as_jsonObject



40
41
42
43
44
45
46
47
# File 'lib/covered/statistics.rb', line 40

def as_json
  {
    count: count,
    executable_count: executable_count,
    executed_count: executed_count,
    percentage: percentage.to_f.round(2),
  }
end

#to_json(options) ⇒ Object



49
50
51
# File 'lib/covered/statistics.rb', line 49

def to_json(options)
  as_json.to_json(options)
end