humanize 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +18 -0
- data/humanize.gemspec +1 -1
- data/lib/humanize.rb +2 -1
- data/spec/tests.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5595ae349abc29a541b952023d0c14ce128c6ac3
|
4
|
+
data.tar.gz: 149b6b7466608e3338e90511dd81b2c58c2dbd6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b0682135ac73f1d79b49c330cda0d114851511553bc65b55f775729f85e7be95ec307e5c158b9a4b923c771a5102a4b1b1e31c0de3bd281088144b79e5d52c
|
7
|
+
data.tar.gz: 12d8a0f92c5aeb93db5f528b28714cce7f7f93013386b0b75414ac9bf6f7998d992edd0017e30fec232029fa669e2d25b7d95ad1684a824d0afc96801ad28c09
|
data/README.markdown
CHANGED
@@ -23,6 +23,24 @@ All the way up to 156 digit numbers:
|
|
23
23
|
|
24
24
|
If you are dealing with numbers larger than 156 digits, we accept patches. Word list is sourced from: [ Wordlist.source ]
|
25
25
|
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### Install the gem using RubyGems
|
29
|
+
|
30
|
+
gem install humanize
|
31
|
+
|
32
|
+
### Include it in your program or add to your Gemfile
|
33
|
+
|
34
|
+
require 'humanize'
|
35
|
+
# or
|
36
|
+
gem 'humanize'
|
37
|
+
|
38
|
+
### Call the method on the numbers
|
39
|
+
|
40
|
+
100.humanize => "one hundred"
|
41
|
+
1001.humanize => "one thousand one"
|
42
|
+
0.001.humanize => "zero point zero zero one"
|
43
|
+
|
26
44
|
## Configuration
|
27
45
|
|
28
46
|
```ruby
|
data/humanize.gemspec
CHANGED
data/lib/humanize.rb
CHANGED
@@ -35,7 +35,8 @@ module Humanize
|
|
35
35
|
o += sets.reverse.join(' ')
|
36
36
|
end
|
37
37
|
if self.class == Float
|
38
|
-
|
38
|
+
digits, exp = to_s.split("e-")
|
39
|
+
decimals = ("%.#{digits[/\d+$/].length + exp.to_i}f" % self).split(/\./, 2).last
|
39
40
|
has_leading_zeroes = decimals[/^0+/].to_s.length > 0
|
40
41
|
decimals_as = :digits if has_leading_zeroes
|
41
42
|
decimals_as_words = case decimals_as
|
data/spec/tests.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
TESTS = [
|
2
2
|
[-1, "negative one"],
|
3
3
|
[-0.042, "negative zero point zero four two"],
|
4
|
+
[-0.00003345, "negative zero point zero zero zero zero three three four five"],
|
5
|
+
[-0.0000017854, "negative zero point zero zero zero zero zero one seven eight five four"],
|
6
|
+
[0.000000123, "zero point zero zero zero zero zero zero one two three"],
|
4
7
|
[0, "zero"],
|
5
8
|
[8.15, "eight point one five"],
|
9
|
+
[8.000015, "eight point zero zero zero zero one five"],
|
6
10
|
[8, "eight"],
|
7
11
|
[11, "eleven"],
|
8
12
|
[21, "twenty-one"],
|