Class: Minitest::Cc::FileArray
- Inherits:
-
Array
- Object
- Array
- Minitest::Cc::FileArray
- Defined in:
- lib/minitest/cc/file_array.rb
Overview
model for a file
Instance Method Summary collapse
-
#branches_average ⇒ Float
Calculate the branches average of the self array.
-
#lines_average ⇒ Float
Calculate the lines average of the self array.
-
#methods_average ⇒ Float
Calculate the methods average of the self array.
-
#total_coverage_percent ⇒ Float
Calculate total average of coverage.
Instance Method Details
#branches_average ⇒ Float
Calculate the branches average of the self array
22 23 24 25 26 27 28 29 |
# File 'lib/minitest/cc/file_array.rb', line 22 def branches_average branches = reduce(0) { |sum, v| sum + v.branches.to_i } return 0.0 if branches.zero? branches_executed = reduce(0) { |sum, v| sum + v.branches_executed.to_i } branches_executed * 100.0 / branches end |
#lines_average ⇒ Float
Calculate the lines average of the self array
10 11 12 13 14 15 16 17 |
# File 'lib/minitest/cc/file_array.rb', line 10 def lines_average lines = reduce(0) { |sum, v| sum + v.lines.to_i } return 0.0 if lines.zero? lines_executed = reduce(0) { |sum, v| sum + v.lines_executed.to_i } lines_executed * 100.0 / lines end |
#methods_average ⇒ Float
Calculate the methods average of the self array
34 35 36 37 38 39 40 41 |
# File 'lib/minitest/cc/file_array.rb', line 34 def methods_average methods = reduce(0) { |sum, v| sum + v.methods.to_i } return 0.0 if methods.zero? methods_executed = reduce(0) { |sum, v| sum + v.methods_executed.to_i } methods_executed * 100.0 / methods end |
#total_coverage_percent ⇒ Float
Calculate total average of coverage
46 47 48 49 50 |
# File 'lib/minitest/cc/file_array.rb', line 46 def total_coverage_percent (lines_average + branches_average + methods_average) / 3 rescue ZeroDivisionError 0.0 end |