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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecc1b9dfee10b96c7606d4c2299e68f2de287e33
4
- data.tar.gz: b43007d515ba0c7bf873814bc1f003ee3ba5335b
3
+ metadata.gz: 5595ae349abc29a541b952023d0c14ce128c6ac3
4
+ data.tar.gz: 149b6b7466608e3338e90511dd81b2c58c2dbd6b
5
5
  SHA512:
6
- metadata.gz: 787080562114cab7b681a9f2b37f6b967905122fc261a7c69467a42262cf0a5f5fda915f2038ad55a840ab8f61bb34c72380a8404a0b63c56edfa2a5d97768f3
7
- data.tar.gz: 58ee321e99baf00c9876b21fa07abf0d6614c5b96dcf2cda8811ada8d551ba12a337dab4343fff4d7083d08c9ee93a42c4a8bbae75e274d47fec22ca358aa76a
6
+ metadata.gz: f6b0682135ac73f1d79b49c330cda0d114851511553bc65b55f775729f85e7be95ec307e5c158b9a4b923c771a5102a4b1b1e31c0de3bd281088144b79e5d52c
7
+ data.tar.gz: 12d8a0f92c5aeb93db5f528b28714cce7f7f93013386b0b75414ac9bf6f7998d992edd0017e30fec232029fa669e2d25b7d95ad1684a824d0afc96801ad28c09
@@ -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
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "humanize"
6
- s.version = "1.6.1"
6
+ s.version = "1.7.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
@@ -35,7 +35,8 @@ module Humanize
35
35
  o += sets.reverse.join(' ')
36
36
  end
37
37
  if self.class == Float
38
- decimals = self.to_s.split(/\./, 2).last
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
@@ -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"],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Chen