read_my_time 0.0.2
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 +7 -0
- data/lib/read_my_time.rb +30 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c5108a67ab69d5fd797c3ed65c0ca1fda1bc5a3e
|
4
|
+
data.tar.gz: a8a52d1bac0ca18579762f395dc3972f06b30ab4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 593e6720b730e58023aa673152c0e152dbbc3179bb55e41c19c4082024fcfbe0d9b2580bd62634ac6b2f97d50871b1043eaa85ef516115d0b4c86494f599cc79
|
7
|
+
data.tar.gz: ba013686744e59bcd29fbd21d6c992a1de26bfaac78cb08d873426bb8b98bcb3969cc2d1f73a747ab63504d04373935987b696fd8efa83e6217c167c8c270fae
|
data/lib/read_my_time.rb
ADDED
@@ -0,0 +1,30 @@
|
|
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] = 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
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: read_my_time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Zaba
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Humanize your times in your locale language
|
14
|
+
email: dpzaba@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/read_my_time.rb
|
20
|
+
homepage: https://github.com/dpzaba/read_my_time
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Humanize your times in your locale language
|
44
|
+
test_files: []
|