tago 0.5.0 → 0.6.0
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/README.md +21 -0
- data/lib/tago.rb +2 -1
- data/tago.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7065628d4d10a5ecb484a5a08973d4091bdcb94858932b7ff353e1472d4572d0
|
|
4
|
+
data.tar.gz: 4f41a9476eb8838e0476e4586e226a81fd7b4874518cc9ab5c856df79e7b56e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b719d14e52e638a19e74d1f25d1c17d5b8e435d88d611fbb91290add6646374639300eb091c711e6e34f000294d28937f12bc3c9e89d70a9e014c7fc763bd775
|
|
7
|
+
data.tar.gz: 6f7d4e72147f350ec57d4bcb9193ec1976e6e8aea47f2e411482b6cbe3dd4acf65fda17e9a7f8bce410b12efd7c4646b69d6c568a9b7e566e9b5d8f05b9ca42e
|
data/README.md
CHANGED
|
@@ -32,6 +32,27 @@ s = Time.now - start
|
|
|
32
32
|
puts "It took #{s.seconds}"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
The `seconds` method accepts optional formatting flags:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
9.444.seconds # => "9s444ms"
|
|
39
|
+
9.444.seconds(:round) # => "9s" (omits sub-units)
|
|
40
|
+
9.444.seconds(:short) # => "9s" (also omits sub-units)
|
|
41
|
+
300.0.seconds(:pretty) # => "five minutes" (words instead of abbreviations)
|
|
42
|
+
300.0.seconds(:pretty, :short) # => "5 min" (numeric with short unit names)
|
|
43
|
+
5.0.seconds(:pretty, :caps) # => "Five seconds" (capitalizes first letter)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The same flags work with `ago`:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
start.ago(:round)
|
|
50
|
+
start.ago(:pretty)
|
|
51
|
+
start.ago(:pretty, :short)
|
|
52
|
+
start.ago(:pretty, :caps)
|
|
53
|
+
start.ago(Time.now, :round)
|
|
54
|
+
```
|
|
55
|
+
|
|
35
56
|
The gem basically extends the `Float` and `Time` classes with new methods.
|
|
36
57
|
|
|
37
58
|
## How to contribute
|
data/lib/tago.rb
CHANGED
|
@@ -56,7 +56,8 @@ class Float
|
|
|
56
56
|
names = locales[:en][:units][unit]
|
|
57
57
|
unit_symbol = val == 1 ? names[0] : names[1]
|
|
58
58
|
unit_name = short ? locales[:en][:short_units][unit] : unit_symbol
|
|
59
|
-
|
|
59
|
+
result = format('%<num>s %<unit_name>s', num:, unit_name:)
|
|
60
|
+
return args.include?(:caps) ? result.capitalize : result
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
if s < 0.001
|
data/tago.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
10
10
|
s.required_ruby_version = '>=3.0'
|
|
11
11
|
s.name = 'tago'
|
|
12
|
-
s.version = '0.
|
|
12
|
+
s.version = '0.6.0'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'A new .ago() method for the Time class'
|
|
15
15
|
s.description =
|