triathlon 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/time_presenter.rb +24 -0
- metadata +5 -4
@@ -0,0 +1,24 @@
|
|
1
|
+
module TimePresenter
|
2
|
+
def present_hours_as_string(time)
|
3
|
+
hours = time.floor
|
4
|
+
fraction = time - hours
|
5
|
+
minutes = (60.0 * fraction)
|
6
|
+
minutes_string = minutes.floor.to_s
|
7
|
+
minutes_string = "0#{minutes_string}" if minutes < 10.0 && hours > 0.0
|
8
|
+
fraction = minutes - minutes.floor
|
9
|
+
seconds = (60.0 * fraction)
|
10
|
+
seconds_string = seconds.round.to_s
|
11
|
+
seconds_string = "0#{seconds_string}" if seconds < 10.0
|
12
|
+
if hours > 0.0
|
13
|
+
"#{hours}:#{minutes_string}:#{seconds_string}"
|
14
|
+
elsif minutes > 0.0
|
15
|
+
"#{minutes_string}:#{seconds_string}"
|
16
|
+
else
|
17
|
+
"0:#{seconds_string}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
def present_seconds_as_string(time_in_seconds)
|
21
|
+
hours = time_in_seconds.to_f / 3600.0
|
22
|
+
present_hours_as_string hours
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triathlon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Waylon Calabrese
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-14 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- lib/bike.rb
|
34
34
|
- lib/converter.rb
|
35
35
|
- lib/splits.rb
|
36
|
+
- lib/time_presenter.rb
|
36
37
|
- test/test_helper.rb
|
37
38
|
- test/unit/test_bike.rb
|
38
39
|
- test/unit/test_converter.rb
|