cogsworth 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/cogsworth.gemspec +1 -1
- data/lib/cogsworth.rb +5 -5
- data/lib/cogsworth/version.rb +1 -1
- metadata +4 -4
data/cogsworth.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Jon buda"]
|
10
10
|
s.email = ["jon.buda@gmail.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/jonbuda/cogsworth"
|
12
12
|
s.summary = %q{A simple natural language time parser for Ruby}
|
13
13
|
s.description = %q{A simple natural language time parser for Ruby}
|
14
14
|
|
data/lib/cogsworth.rb
CHANGED
@@ -13,15 +13,15 @@ module Cogsworth
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def unparse(seconds,
|
17
|
-
return
|
16
|
+
def unparse(seconds, results=[])
|
17
|
+
return results.join(' ') if seconds == 0
|
18
18
|
|
19
19
|
['d','h','m','s'].each do |unit|
|
20
|
-
|
21
|
-
return unparse(seconds%MULTIPLIERS[unit],
|
20
|
+
occurrences = seconds/MULTIPLIERS[unit]
|
21
|
+
return unparse(seconds%MULTIPLIERS[unit], results.push("#{occurrences}#{unit}")) if occurrences > 0
|
22
22
|
end
|
23
23
|
|
24
|
-
return unparse(seconds,
|
24
|
+
return unparse(seconds, results)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/cogsworth/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cogsworth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon buda
|
@@ -55,7 +55,7 @@ files:
|
|
55
55
|
- spec/cogsworth_spec.rb
|
56
56
|
- spec/spec_helper.rb
|
57
57
|
has_rdoc: true
|
58
|
-
homepage:
|
58
|
+
homepage: https://github.com/jonbuda/cogsworth
|
59
59
|
licenses: []
|
60
60
|
|
61
61
|
post_install_message:
|