Class: Coverage::Statistics

Inherits:
Object
  • Object
show all
Defined in:
lib/coverage/statistics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, counts) ⇒ Statistics

Returns a new instance of Statistics.



6
7
8
9
# File 'lib/coverage/statistics.rb', line 6

def initialize(path, counts)
  @path = path
  @counts = counts
end

Instance Attribute Details

#countsObject (readonly)

Returns the value of attribute counts.



4
5
6
# File 'lib/coverage/statistics.rb', line 4

def counts
  @counts
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/coverage/statistics.rb', line 4

def path
  @path
end

Instance Method Details

#code_coverageObject



23
24
25
# File 'lib/coverage/statistics.rb', line 23

def code_coverage
  "%.2f" % [(lines_of_covered_code / lines_of_code.to_f) * 100]
end

#lines_of_codeObject



15
16
17
# File 'lib/coverage/statistics.rb', line 15

def lines_of_code
  counts.compact.size
end

#lines_of_covered_codeObject



27
28
29
# File 'lib/coverage/statistics.rb', line 27

def lines_of_covered_code
  counts.select{|count| count && count > 0 }.size
end

#totalObject



11
12
13
# File 'lib/coverage/statistics.rb', line 11

def total
  counts.size
end

#total_coverageObject



19
20
21
# File 'lib/coverage/statistics.rb', line 19

def total_coverage
  "%.2f" % [(lines_of_covered_code / total.to_f) * 100]
end