nreadable 0.2.0 → 0.2.1
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 +12 -1
- data/lib/nreadable.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f65eddd89473e064cbe99663c65ce73a797bb1b
|
|
4
|
+
data.tar.gz: a9fe19b9fc2b1ee4d23a406aa8c01cd9c3b8d008
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 521fe733fc0845ed44bfb92d68a345c5b498f76efa8c31509e9d4c302e1a222b4f674d885b61ad3c94e2fac74ca4e9447268ad16ff384745aa1a4388a53659e8
|
|
7
|
+
data.tar.gz: 6042e28bde41ae38e649edabdeac59c4b3f603c0790df2db8cce3cc1d1c865495fbd4f5a44bcf2f5c5ce4a888847c5284dac3f497ab5597a46afdfcd90dc91f1
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# nreadable
|
|
2
2
|
Extends the Numeric Class with the ability to create better readable representations of numeric values as a String.
|
|
3
3
|
|
|
4
|
+
gem install nreadable
|
|
5
|
+
|
|
4
6
|
## Features
|
|
5
7
|
- thousands separated numbers ( e.g. 1,000,000 )
|
|
6
8
|
- exponential notation with self-adjusting precision ( e.g. 1e+06 )
|
|
@@ -8,6 +10,15 @@ Extends the Numeric Class with the ability to create better readable representat
|
|
|
8
10
|
- Binary Prefixes ( e.g. 1048576 = 1Mi )
|
|
9
11
|
- large-number naming system ( e.g. 1 million )
|
|
10
12
|
|
|
13
|
+
## Usage
|
|
14
|
+
1000.delimited #=> "1,000"
|
|
15
|
+
123000000.scientific #=> "1.23e+08"
|
|
16
|
+
123000000.si_prefixed #=> "123M"
|
|
17
|
+
0.000123.si_prefixed #=> "123µ"
|
|
18
|
+
123000000.bin_prefixed #=> "117.3Mi"
|
|
19
|
+
123000000.named #=> "123 million"
|
|
20
|
+
for more details and options, see http://rubydoc.info/gems/nreadable/0.2.1/Numeric
|
|
21
|
+
|
|
11
22
|
## License
|
|
12
23
|
The MIT license. See LICENSE file.
|
|
13
24
|
|
data/lib/nreadable.rb
CHANGED
|
@@ -62,7 +62,7 @@ class Numeric
|
|
|
62
62
|
# An exponential notation is used if the number is >= 1000 or < 0.01.
|
|
63
63
|
# @param precision [Integer] the maximum precision. Only applies if the
|
|
64
64
|
# exponential notation is used. Must be >= 0.
|
|
65
|
-
# @return [String] the
|
|
65
|
+
# @return [String] the formatted number.
|
|
66
66
|
# @example
|
|
67
67
|
# 12.55.scientific #=> "12.55"
|
|
68
68
|
# 10000.scientific #=> "1e+04"
|
|
@@ -83,7 +83,7 @@ class Numeric
|
|
|
83
83
|
|
|
84
84
|
# Creates a representation of the number with a SI prefix attached.
|
|
85
85
|
# @param precision [Integer] maximum precision. Must be >= 0.
|
|
86
|
-
# @return [String] the
|
|
86
|
+
# @return [String] the formatted number.
|
|
87
87
|
# @example
|
|
88
88
|
# 0.0000012.si_prefixed #=> "1.2µ"
|
|
89
89
|
# 1000.si_prefixed #=> "1k"
|
|
@@ -130,7 +130,7 @@ class Numeric
|
|
|
130
130
|
# @param precision [Integer] maximum precision. Must be >= 0.
|
|
131
131
|
# @return [String] the formatted number.
|
|
132
132
|
# @example
|
|
133
|
-
# 2000.named #=> "2
|
|
133
|
+
# 2000.named #=> "2 thousand"
|
|
134
134
|
# 2_310_000.named #=> "2.3 million"
|
|
135
135
|
|
|
136
136
|
def named( precision = 1 )
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nreadable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Markus Anders
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-09-
|
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
Extends the Numeric Class with the ability to create better readable
|