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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/lib/tago.rb +2 -1
  4. data/tago.gemspec +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c58f911880a7e18c878c6d586393e785b4552205d5c9d489dcbf72e7aaab455
4
- data.tar.gz: de65be56f9a1df5f45343644b50f27496c2daebdb423c4788b085803d8c17bd3
3
+ metadata.gz: 7065628d4d10a5ecb484a5a08973d4091bdcb94858932b7ff353e1472d4572d0
4
+ data.tar.gz: 4f41a9476eb8838e0476e4586e226a81fd7b4874518cc9ab5c856df79e7b56e1
5
5
  SHA512:
6
- metadata.gz: c797174c8dc2d002dffc12422f33e70d979fdc73c98150ea52e563cc0581f757444fca01fb492024736bc06c2edce67c6a0db136d57b410322770aae90dae7ff
7
- data.tar.gz: cd6a4c966a36c85c7e1a8ac0f6cef233070b13e91c60375b543b44a431e55cb466d5d38b680a943a8426e62dae1599f0dd5f50824d847e0ff0237c5244f2d018
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
- return format('%<num>s %<unit_name>s', num:, unit_name:)
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.5.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 =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko