Jldrill Git C0 Coverage Information - RCov

lib/jldrill/model/Duration.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/jldrill/model/Duration.rb 65 36
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 
3     # Holds a duration in seconds.  Note that this is an integer value
4     # and can't be used for small measurements. A value less than zero
5     # means that it is an invalid duration.  Also since it is a signed
6     # int you should refrain from using values larger than about 68 years
7     
8     class Duration
9 
10         def initialize(seconds = -1)
11             @seconds = seconds
12         end
13 
14         # assigns this duration to be the same as the one passed in
15         def assign(duration)
16             @seconds = duration.seconds
17         end
18 
19         # Returns the duration in seconds
20         def seconds
21             return @seconds
22         end
23 
24         # Sets the duration to be equal to the number of seconds passed in
25         def seconds=(seconds)
26             @seconds = seconds
27         end
28 
29         # Returns the duration in days as a floating point number
30         def days
31             return @seconds.to_f / 60.0 / 60.0 / 24.0
32         end
33 
34         # Sets the duration to be the number of days passed in.  If this
35         # happens to end up as a fraction of seconds, the result is truncated.
36         def days=(days)
37             @seconds = (days * 24 * 60 * 60).to_i
38         end
39 
40         # Takes an integer as a string and returns a duration.
41         def Duration.parse(string)
42             duration = string.to_i
43             # When to_i fails, it returns 0.  We need to differential
44             # between that and a real 0.
45             if (duration != 0) || string.start_with?("0")
46                 return Duration.new(duration)
47             else
48                 # Return an invalid Duration
49                 return Duration.new()
50             end
51         end
52 
53         # Returns false if the duration isn't valid
54         def valid?
55             return (@seconds >= 0)
56         end
57 
58         # Returns the duration as a string representing the number of seconds
59         def to_s
60             return @seconds.to_s
61         end
62     end
63 end
64 
65 

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