numbertotext-ruby 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 648a8f9b8f448c41208dd6d36fc8f5bfb8091a3e
4
- data.tar.gz: eb8736bdf21bee2b440ca7b437e17d2543e631a6
3
+ metadata.gz: 68bddb6dae31e1b8595a77c4eb5e30bf5b6bf05d
4
+ data.tar.gz: 3918d5ba5f1ea103365e9b55e35613790d5ba20b
5
5
  SHA512:
6
- metadata.gz: 35e4b388284ee17913ea084bcf03254569b04cabb1876f1d84c0860b1b48588b3045cb268de6d76d3e6aa837556c655f13dd3db82c8b0593a7ccb65cdecaa7c8
7
- data.tar.gz: abd1ad9003ae0ca4d7503ee9b79aae0145edfd5f40abf1f6a787ff4045d97a6ad1f5db1d61aa2b97437e56edb8abbc7b8d2613e6d3bbc0aafaaedb0c05f6515f
6
+ metadata.gz: 4a9d4a36d28e991e09cc40a2d54aa4cd31b63692ed4bd7619c7b42dfe82a75413d3c4b895a9a0e1c43d4a245a31e5eefe08583a05ddb59470b06d7859c155a7b
7
+ data.tar.gz: 27a9113f36d6f2c7ef76194486a8921ced5bb820894e536da0239d929a15db9de3f210bde4d6460c449de71284a32ff25d761317681a77855a910a7148d0cdcf
data/README.md CHANGED
@@ -14,6 +14,20 @@ Or install it yourself as:
14
14
 
15
15
  $ gem install numbertotext-ruby
16
16
 
17
+ ## Usage
18
+
19
+ Require the numbertotext library
20
+
21
+ require 'numbertotext'
22
+
23
+ Convert a number you want (e.g. 1000)
24
+
25
+ NumberToText.convert(1000)
26
+
27
+ Alternatively, you could also convert a number by simply calling the "to_text" method on it
28
+
29
+ 1000.to_text = "one thousand"
30
+
17
31
 
18
32
  ## Contributing
19
33
 
data/lib/numbertotext.rb CHANGED
@@ -28,7 +28,9 @@ module NumberToText
28
28
 
29
29
 
30
30
  def self.convert(number)
31
- if number < 20
31
+ if number < 0
32
+ return 'minus ' + convert(-1*number)
33
+ elsif number < 20 && number > -1
32
34
  return @dictionary1[number]
33
35
  elsif number < 100 && number > 19
34
36
  convert_20_to_99(number)
@@ -44,5 +46,10 @@ module NumberToText
44
46
  return 'number too large. please try with a number lower than or equal to 999999999999'
45
47
  end
46
48
  end
47
-
48
49
  end
50
+
51
+ class Fixnum
52
+ def to_text
53
+ NumberToText.convert(self)
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module NumberToText
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -22,6 +22,12 @@ describe NumberToText do
22
22
  expect(actual).to eq(expected)
23
23
  end
24
24
 
25
+ it 'should convert 20' do
26
+ actual = 20.to_text
27
+ expected = 'twenty'
28
+ expect(actual).to eq(expected)
29
+ end
30
+
25
31
  it 'should convert 21' do
26
32
  actual = NumberToText.convert(21)
27
33
  expected = 'twenty-one'
@@ -149,4 +155,10 @@ describe NumberToText do
149
155
  expect(actual).to eq(expected)
150
156
  end
151
157
 
158
+ it 'should convert -1000' do
159
+ actual = NumberToText.convert(-1000)
160
+ expected = 'minus one thousand'
161
+ expect(actual).to eq(expected)
162
+ end
163
+
152
164
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numbertotext-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edem Kumodzi