attentive 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attentive/duration.rb +17 -7
- data/lib/attentive/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d538262cfb344744d56a62ab0c55ead35d0513
|
4
|
+
data.tar.gz: 2cf0add3bcd0f0a0535d449fc4cd3df181315486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4f978dd2eeab193511fc4e19aba9860d5c7407b825a459db411d81bdae24e4692de47aedf9598cda634d774904456d3192f686b4acb67fdf6b333bea965ea9f
|
7
|
+
data.tar.gz: d2ea36e5454a21a65c1f75b288fbfc2439a8d892255a8e07d917bc45520d97612ceb428bba4d1d654d81ddb93c31ca17eea1298180d35101e70186e8ffcda909
|
data/lib/attentive/duration.rb
CHANGED
@@ -22,14 +22,24 @@ module Attentive
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def inspect
|
25
|
+
"<#{to_s}>"
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s
|
25
29
|
phrases = []
|
26
|
-
phrases.push "#{years} years" if years > 0
|
27
|
-
phrases.push "#{months} months" if months > 0
|
28
|
-
phrases.push "#{days} days" if days > 0
|
29
|
-
phrases.push "#{hours} hours" if hours > 0
|
30
|
-
phrases.push "#{minutes} minutes" if minutes > 0
|
31
|
-
phrases.push "#{seconds} seconds" if seconds > 0
|
32
|
-
|
30
|
+
phrases.push "#{years} #{years > 1 ? "years" : "year"}" if years > 0
|
31
|
+
phrases.push "#{months} #{months > 1 ? "months" : "month"}" if months > 0
|
32
|
+
phrases.push "#{days} #{days > 1 ? "days" : "day"}" if days > 0
|
33
|
+
phrases.push "#{hours} #{hours > 1 ? "hours" : "hour"}" if hours > 0
|
34
|
+
phrases.push "#{minutes} #{minutes > 1 ? "minutes" : "minute"}" if minutes > 0
|
35
|
+
phrases.push "#{seconds} #{seconds > 1 ? "seconds" : "second"}" if seconds > 0
|
36
|
+
|
37
|
+
case phrases.length
|
38
|
+
when 0 then ""
|
39
|
+
when 1 then phrases[0]
|
40
|
+
when 2 then phrases.join(" and ")
|
41
|
+
else "#{phrases[0...-1].join(", ")}, and #{phrases[-1]}"
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
def after(date)
|
data/lib/attentive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attentive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|