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.
- checksums.yaml +4 -4
- data/lib/pretty_floats.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f32d365b5a3e263692ea64cfc4671722c6e4ca03a944e8a7bd0e7f9ee223c4b
|
4
|
+
data.tar.gz: ea4dd60168199900edefddd805870793b6ddbf613d9a950531ef45d37348404e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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:
|
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-
|
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
|