read_my_time 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/numeric.rb +32 -0
- data/lib/read_my_time.rb +1 -30
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbab0018f15d0667c989e9997ed56a29fcdb71a
|
4
|
+
data.tar.gz: 6e59d40dca574b3eeb012e1dcae5c4b002f9c2ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99bb2001aadbdc5765714f3e4bcfa7fee63660442aa883f8c377b98fbeccff2b648e9a8245877e510374dc5e02480a09bd9f93fa4384c448082205c2bf3fecbe
|
7
|
+
data.tar.gz: a66b66d7da69e621c30eb9b59e0116b139e98a9f95f2400ecb116f992e781a6eebb8e0da0205b3ae2a00db2c2822befe9cf46b1acc79aa1a3ef05dff20e6e88f
|
data/lib/numeric.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class Numeric
|
2
|
+
|
3
|
+
def seconds_in_words(opts = {})
|
4
|
+
seconds_int = self.to_i
|
5
|
+
|
6
|
+
return '' if seconds_int <= 0
|
7
|
+
|
8
|
+
# options by default
|
9
|
+
opts[:skip_seconds] = false if opts[:skip_seconds].nil?
|
10
|
+
|
11
|
+
unit_time_dividers = {
|
12
|
+
seconds: 60,
|
13
|
+
minutes: 60,
|
14
|
+
hours: 24,
|
15
|
+
days: 365
|
16
|
+
}
|
17
|
+
|
18
|
+
unit_time_dividers.inject([]) do |s, (unit_time, divider)|
|
19
|
+
|
20
|
+
if seconds_int > 0
|
21
|
+
seconds_int, rest = seconds_int.divmod(divider)
|
22
|
+
|
23
|
+
if rest.nonzero? && !(unit_time == :seconds && opts[:skip_seconds])
|
24
|
+
s.unshift("#{rest} #{unit_time}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
s
|
28
|
+
end.join(' ')
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/read_my_time.rb
CHANGED
@@ -1,30 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def seconds_in_words(opts = {})
|
4
|
-
seconds_int = self.to_i
|
5
|
-
|
6
|
-
return '' if seconds_int <= 0
|
7
|
-
|
8
|
-
# options by default
|
9
|
-
opts[:skip_seconds] = true if opts[:skip_seconds].nil?
|
10
|
-
|
11
|
-
{
|
12
|
-
seconds: 60,
|
13
|
-
minutes: 60,
|
14
|
-
hours: 24,
|
15
|
-
days: 365
|
16
|
-
}.inject([]) do |s, (unit_time, divider)|
|
17
|
-
|
18
|
-
if seconds_int > 0
|
19
|
-
seconds_int, rest = seconds_int.divmod(divider)
|
20
|
-
|
21
|
-
if rest.nonzero? && !(unit_time == :seconds && opts[:skip_seconds])
|
22
|
-
s.unshift("#{rest} #{unit_time}")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
s
|
26
|
-
end.join(' ')
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
1
|
+
require 'numeric'
|
metadata
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: read_my_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Zaba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Humanize your times in your locale language
|
13
|
+
description: Humanize your times in your locale language. It is plain Ruby, you don't
|
14
|
+
need Rails or Sinatra, but it works great with them also.
|
14
15
|
email: dpzaba@gmail.com
|
15
16
|
executables: []
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- lib/numeric.rb
|
19
21
|
- lib/read_my_time.rb
|
20
22
|
homepage: https://github.com/dpzaba/read_my_time
|
21
23
|
licenses:
|