Class: Coverage::Statistics
- Inherits:
-
Object
- Object
- Coverage::Statistics
- Defined in:
- lib/coverage/statistics.rb
Instance Attribute Summary collapse
-
#counts ⇒ Object
readonly
Returns the value of attribute counts.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #code_coverage ⇒ Object
-
#initialize(path, counts) ⇒ Statistics
constructor
A new instance of Statistics.
- #lines_of_code ⇒ Object
- #lines_of_covered_code ⇒ Object
- #total ⇒ Object
- #total_coverage ⇒ Object
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
#counts ⇒ Object (readonly)
Returns the value of attribute counts.
4 5 6 |
# File 'lib/coverage/statistics.rb', line 4 def counts @counts end |
#path ⇒ Object (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_coverage ⇒ Object
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_code ⇒ Object
15 16 17 |
# File 'lib/coverage/statistics.rb', line 15 def lines_of_code counts.compact.size end |
#lines_of_covered_code ⇒ Object
27 28 29 |
# File 'lib/coverage/statistics.rb', line 27 def lines_of_covered_code counts.select{|count| count && count > 0 }.size end |
#total ⇒ Object
11 12 13 |
# File 'lib/coverage/statistics.rb', line 11 def total counts.size end |
#total_coverage ⇒ Object
19 20 21 |
# File 'lib/coverage/statistics.rb', line 19 def total_coverage "%.2f" % [(lines_of_covered_code / total.to_f) * 100] end |