pretty_floats 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pretty_floats.rb +2 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac694981f780e140d427ed58db1c226cd1bc861b1854301635d878fcf1b1072e
4
- data.tar.gz: 0ac9e1aef495355ee7b2ad206c9bc038b01bbbd5fb33f35b585a7f4a98ee4e5e
3
+ metadata.gz: 7f32d365b5a3e263692ea64cfc4671722c6e4ca03a944e8a7bd0e7f9ee223c4b
4
+ data.tar.gz: ea4dd60168199900edefddd805870793b6ddbf613d9a950531ef45d37348404e
5
5
  SHA512:
6
- metadata.gz: 5d403cc2ed314750ad9cc952d2de7fd9ac0b5da75662cb74963b28cbd46ac40c045b27f7480f1c75e4c554504b65e0905a9046770cd4054aba26b257a01930bd
7
- data.tar.gz: ac96e21461da3027a84bea162bb2e8395a071ae301d36a6f78e5c524406141bd64cc5764b2015d763c21fb9494ca73d6c815baea2e400df35102738943fe6f33
6
+ metadata.gz: 626448b6757eb7a533fa8d4ea86848b8ed28fd1e607d43a8f7dc9097e5bec70537fef232c3bae5afc8f0f1b631d055c8cf908915092f1fa45df3c1b9bc657fb9
7
+ data.tar.gz: 9d5ae8fac0c7199c07dff986fa8fb11132eef9b80e5cfea53090a89b2f939198e9bb28e7d8def31f7b12a6a20c3f29bf6431155e875ff191376a92ddd05a2176
data/lib/pretty_floats.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Float
2
2
  # changes numbers like 1234567 to "1,234,567"
3
- def prettify(place_sep=',', radix_sep='.')
3
+ def prettify(place_sep: ',', radix_sep: '.', num_places: -1)
4
4
  int = self
5
5
  .to_i
6
6
  .to_s
@@ -11,7 +11,7 @@ class Float
11
11
  .join(place_sep)
12
12
  .reverse
13
13
 
14
- max_digits = self.to_s.split('.').last.length
14
+ max_digits = num_places == -1 ? self.to_s.split('.').last.length : num_places
15
15
  float = (self % 1)
16
16
  .round(max_digits)
17
17
  .to_s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_floats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-18 00:00:00.000000000 Z
11
+ date: 2023-09-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a small utility to format floating point numbers for easier reading
14
14
  email: jefflunt@gmail.com