timer.rb 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -1
- data/lib/timer/time_parser.rb +5 -5
- data/lib/timer/version.rb +1 -1
- metadata +3 -4
- data/bin/foo.rb +0 -3
data/README.markdown
CHANGED
data/lib/timer/time_parser.rb
CHANGED
@@ -15,14 +15,14 @@ module Timer
|
|
15
15
|
time_chunks = duration
|
16
16
|
end
|
17
17
|
|
18
|
-
time_chunks.reject! { |c| c !~ /\d+[mhs]$/ }
|
18
|
+
time_chunks.reject! { |c| c !~ /\d+(\.\d+)?[mhs]$/ }
|
19
19
|
hours += time_chunks.select {|c| c[-1,1] == "h" }
|
20
20
|
mins += time_chunks.select {|c| c[-1,1] == "m" }
|
21
21
|
secs += time_chunks.select {|c| c[-1,1] == "s" }
|
22
22
|
|
23
|
-
total += hours.inject(0) { |sum, x| sum + (x.
|
24
|
-
total += mins.inject(0) { |sum, x| sum + (x.
|
25
|
-
total += secs.inject(0) { |sum, x| sum + x.
|
23
|
+
total += hours.inject(0) { |sum, x| sum + (x.to_f * 3600) }
|
24
|
+
total += mins.inject(0) { |sum, x| sum + (x.to_f * 60) }
|
25
|
+
total += secs.inject(0) { |sum, x| sum + x.to_f }
|
26
26
|
|
27
27
|
# nil otherwise
|
28
28
|
total unless total == 0
|
@@ -30,4 +30,4 @@ module Timer
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
Timer::TimeParser.parse_duration("0.5m")
|
data/lib/timer/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timer.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Federico Builes
|
@@ -58,7 +58,6 @@ files:
|
|
58
58
|
- lib/timer/timer.rb
|
59
59
|
- lib/timer/version.rb
|
60
60
|
- lib/timer.rb
|
61
|
-
- bin/foo.rb
|
62
61
|
- bin/timer.rb
|
63
62
|
has_rdoc: false
|
64
63
|
homepage: http://github.com/febuiles/timer.rb
|
data/bin/foo.rb
DELETED