Jldrill Git C0 Coverage Information - RCov

lib/jldrill/model/Quiz/LevelStats.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/jldrill/model/Quiz/LevelStats.rb 39 25
100.00%
100.00%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 module JLDrill
2     # Keeps track of statistics for a particular level
3     # @num is the number of tries, @correct is the number that
4     # were correct.
5     class LevelStats
6         def initialize
7             @num = 0
8             @correct = 0
9         end
10         
11         # Indicate that a trial was correct    
12         def correct
13             @correct += 1
14             @num += 1
15         end
16         
17         # Indicate that a trial was incorrect    
18         def incorrect
19             @num += 1
20         end
21         
22         # The total number of trials    
23         def total
24             @num
25         end
26         
27         # Returns the percentage of items scored correctly.
28         # Note this returns an integer from 0 to 100.  If the
29         # percentage included a fraction, the fraction is truncated.
30         def accuracy
31             if @num > 0
32                 ((@correct.to_f / @num.to_f) * 100).to_i
33             else
34                 nil
35             end
36         end
37     end
38 end
39 

Generated on Mon May 23 16:17:46 +0900 2011 with rcov 0.9.8