to_words 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/to_words.rb +7 -2
- data/lib/to_words/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmYwMzQyMTIwNDkzMWE5NjlkMjAzMGJhZTZmMDQ0YjNmYzQxOGEwOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGVmMTA3NmI2NTdkZWU4OGM1YTM1YjhiNzA2MTg1YzY4NWY1ZDU1Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWMxNjcxMzJjMGYwMDdkMTE0MzNlNjVkMmRhMDM4OTJlYTNkMmFlNzM5NzU3
|
10
|
+
NDdlZmFhYTUwOGZjZTNjMzYyZGM3NjZkOGVlMTU5NWQ4ZGQzNWM0YzExYmVm
|
11
|
+
NzkzOGNhMDYxOTQ4ZGMyNzFmOGFiOTBmZWI5YmI1ZjFiMTYyZTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDEyOGViZGEyM2QyNTQxYWU0OGI4YmYyNTE5ZTU0NWExZTBmMDI5NmMyNzkw
|
14
|
+
YWIzYjUwNWJhYmIwNDc2ZThkY2U4NTUwNTYxYjQ0N2I0MDg1MjZjNDI5N2Y0
|
15
|
+
MDhhN2E1ZjRjZDljNTBlZDRkMjAxMTAxZmVmYmM2OWM4NGMyYWQ=
|
data/lib/to_words.rb
CHANGED
@@ -7,7 +7,8 @@ module ToWords
|
|
7
7
|
|
8
8
|
def to_words
|
9
9
|
num = self.to_i
|
10
|
-
|
10
|
+
num, sign = check_sign(num)
|
11
|
+
return (sign + UNDER_HUNDRED[num]) if num <= 100
|
11
12
|
counter = 0
|
12
13
|
result = []
|
13
14
|
while num != 0
|
@@ -16,7 +17,7 @@ module ToWords
|
|
16
17
|
result << temp_result + " " + DIVISIONS[counter] + " " if temp_result != ''
|
17
18
|
counter += 1
|
18
19
|
end
|
19
|
-
return result.reverse.join(", ").rstrip
|
20
|
+
return sign + result.reverse.join(", ").rstrip
|
20
21
|
end
|
21
22
|
|
22
23
|
def result_below_one_thousand(num, counter)
|
@@ -27,6 +28,10 @@ module ToWords
|
|
27
28
|
return UNDER_HUNDRED[hundred] + " Hundred " if hundred != 0 && remaining == 0
|
28
29
|
return ''
|
29
30
|
end
|
31
|
+
|
32
|
+
def check_sign(num)
|
33
|
+
return num < 0 ? ([num.abs, 'negative ']) : ([num, ''])
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
class Fixnum
|
data/lib/to_words/version.rb
CHANGED