say_number 0.3.0 → 1.0.0
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 +20 -5
- data/lib/say_number.rb +29 -2
- data/lib/say_number/languages/english.rb +249 -239
- data/lib/say_number/languages/indonesia.rb +345 -335
- data/lib/say_number/version.rb +1 -1
- data/say_number.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 806c4ae40850ffbc87958d641f05699aa7cd574f
|
|
4
|
+
data.tar.gz: 1d80fb677a6edf870bd8ce07ed859a2f5a0e1e1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 243f9dea9db65f23190ff782c57df46f477d0f0a0711171132ac4b1c0ddeedbae4fa5aee5d8605a258e654964c77a6b4da1ae6372580b48c3c1aef71bb94f915
|
|
7
|
+
data.tar.gz: 097e2d2770935adbcc5018f19c7bc5e28a9385aba0720a312aa26ebb62b4f3101db22cb9c4c6ac9a1dfc782cbc42508bdf389e710f687fb7fefc876190c5cac8
|
data/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# SayNumber
|
|
2
2
|
|
|
3
|
-
SayNumber is a simple gem that say the given number
|
|
3
|
+
SayNumber is a simple gem that say the given number in word
|
|
4
4
|
|
|
5
5
|
available in two language:
|
|
6
|
-
|
|
7
|
-
:
|
|
6
|
+
|
|
7
|
+
:id = Indonesia (default)
|
|
8
|
+
|
|
9
|
+
:en = English
|
|
8
10
|
|
|
9
11
|
the maximum limit number for now is 999,999,999,999,999
|
|
10
12
|
|
|
@@ -24,7 +26,7 @@ Or install it yourself as:
|
|
|
24
26
|
|
|
25
27
|
## Usage
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
put the number in the SayNumber.say() function
|
|
28
30
|
|
|
29
31
|
example :
|
|
30
32
|
|
|
@@ -34,7 +36,7 @@ it will generate
|
|
|
34
36
|
|
|
35
37
|
"seratus ribu tiga ratus dua puluh"
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
in english you need to put :en in parameter say(number, :en)
|
|
38
40
|
|
|
39
41
|
SayNumber.say(100320, :en)
|
|
40
42
|
|
|
@@ -44,16 +46,29 @@ it will generate
|
|
|
44
46
|
|
|
45
47
|
*note : I leave the 'and' because I don't really know where to put it, any suggestion or reference page would be great.
|
|
46
48
|
|
|
49
|
+
with the latest version (1.0.0), you will be able to pass float number and get the point (koma) in word
|
|
50
|
+
|
|
51
|
+
SayNumber.say(1234.123) # seribu dua ratus tiga puluh empat koma satu dua tiga
|
|
52
|
+
|
|
53
|
+
SayNumber.say(1234.123, :en) # one thousand two hundred thirty four point one two three
|
|
54
|
+
|
|
55
|
+
if you want to get the exact value behind the float point, make sure you pass it as a string because Ruby will round it up automatically.
|
|
56
|
+
|
|
57
|
+
see the spec for more example
|
|
47
58
|
|
|
48
59
|
be careful with the number that you parse, ruby can't take a leading 0, in example if you pass
|
|
49
60
|
|
|
50
61
|
SayNumber.say(0123) # delapan puluh tiga
|
|
51
62
|
|
|
63
|
+
SayNumber.say(0123) # eighty three
|
|
64
|
+
|
|
52
65
|
the result would be far from expected, because Ruby will take it as hexadecimal, not octal number.
|
|
53
66
|
To make sure you pass the right number, you can pass it as string instead of number
|
|
54
67
|
|
|
55
68
|
SayNumber.say("0123") # seratus dua puluh tiga
|
|
56
69
|
|
|
70
|
+
SayNumber.say("0123", :en) # one hundred twenty three
|
|
71
|
+
|
|
57
72
|
if you want to show the result in UPPERCASE or Capitalize, you can simple put upcase or capitalize in the end of the say() function
|
|
58
73
|
|
|
59
74
|
SayNumber.say(123).upcase # SERATUS DUA PULUH TIGA
|
data/lib/say_number.rb
CHANGED
|
@@ -24,6 +24,7 @@ module SayNumber
|
|
|
24
24
|
def self.say(number, language = :id)
|
|
25
25
|
if language == :id
|
|
26
26
|
Indonesia.initialize_sayer
|
|
27
|
+
@koma = get_koma(number)
|
|
27
28
|
@separated = digit_separator(number.to_i)
|
|
28
29
|
@array = @separated.split(".")
|
|
29
30
|
@length = @array.count
|
|
@@ -32,9 +33,16 @@ module SayNumber
|
|
|
32
33
|
@saying.push(Indonesia.get_number_sayer_per_separator(i, @array[i]))
|
|
33
34
|
end
|
|
34
35
|
@saying = @saying.reverse.join(" ")
|
|
35
|
-
|
|
36
|
+
if @koma.nil?
|
|
37
|
+
result = Indonesia.check_nol(@saying).first.strip
|
|
38
|
+
else
|
|
39
|
+
koma = Indonesia.say_koma(@koma)
|
|
40
|
+
result = Indonesia.check_nol(@saying).first.strip
|
|
41
|
+
return "#{result} #{koma}"
|
|
42
|
+
end
|
|
36
43
|
elsif language == :en
|
|
37
44
|
English.initialize_sayer
|
|
45
|
+
@koma = get_koma(number)
|
|
38
46
|
@separated = digit_separator(number.to_i)
|
|
39
47
|
@array = @separated.split(".")
|
|
40
48
|
@length = @array.count
|
|
@@ -43,9 +51,28 @@ module SayNumber
|
|
|
43
51
|
@saying.push(English.get_number_sayer_per_separator(i, @array[i]))
|
|
44
52
|
end
|
|
45
53
|
@saying = @saying.reverse.join(" ")
|
|
46
|
-
|
|
54
|
+
if @koma.nil?
|
|
55
|
+
result = English.check_nol(@saying).first.strip
|
|
56
|
+
else
|
|
57
|
+
koma = English.say_koma(@koma)
|
|
58
|
+
result = English.check_nol(@saying).first.strip
|
|
59
|
+
return "#{result} #{koma}"
|
|
60
|
+
end
|
|
47
61
|
else
|
|
48
62
|
raise "Unknown Language"
|
|
49
63
|
end
|
|
50
64
|
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
def self.get_koma(number)
|
|
68
|
+
splited = number.to_s.split(".")
|
|
69
|
+
zero = [0]
|
|
70
|
+
if splited.count == 2 && splited.last != "0"
|
|
71
|
+
# normalize the floating point .00
|
|
72
|
+
koma = zero.push(splited.last).join(".").to_f
|
|
73
|
+
return koma.to_s.split(".").last
|
|
74
|
+
else
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
end
|
|
51
78
|
end
|
|
@@ -1,263 +1,273 @@
|
|
|
1
1
|
class English
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
def self.initialize_sayer
|
|
3
|
+
@satuan_en = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
|
|
4
|
+
@teen = {10=>"ten", 11=>"eleven", 12=>"twelve", 13=>"thirteen", 14=>"fourteen", 15=>"fifteen", 16=>"sixteen", 17=>"seventeen", 18=>"eighteen", 19=>"nineteen"}
|
|
5
|
+
@anomalies = {20=>"twenty", 30=>"thirty", 40=>"fourty", 50=>"fifty", 60=>"sixty", 70=>"seventy", 80=>"eighty", 90=>"ninety", 100=>"hundred", 1000=>"thousand", 1000000=>"million", 1000000000=>"billion", 1000000000000=>"trillion", 1000000000000000=>"quadrillion"}
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.say_koma(koma)
|
|
9
|
+
@koma = []
|
|
10
|
+
@koma.push("point")
|
|
11
|
+
@temp = koma.to_s.split("")
|
|
12
|
+
@temp.each do |k|
|
|
13
|
+
@koma.push(@satuan_en[k.to_i])
|
|
14
|
+
end
|
|
15
|
+
return @koma.join(" ")
|
|
16
|
+
end
|
|
7
17
|
|
|
8
18
|
def self.get_number_sayer_ratusan(number)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
19
|
+
@sayer = []
|
|
20
|
+
@temp = number.first
|
|
21
|
+
if number.count == 1
|
|
22
|
+
return @sayer.push(@satuan_en[@temp])
|
|
23
|
+
elsif number.count == 2
|
|
24
|
+
if number[1] == 1
|
|
25
|
+
@sayer.push(@teen[10+@temp])
|
|
26
|
+
else
|
|
27
|
+
if @temp != 0
|
|
28
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp])
|
|
29
|
+
else
|
|
30
|
+
@sayer.push(@anomalies[number[1]*10])
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
return @sayer
|
|
34
|
+
elsif number.count == 3
|
|
35
|
+
if number.last == 0
|
|
36
|
+
else
|
|
37
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
38
|
+
end
|
|
39
|
+
if number[1] == 1
|
|
40
|
+
@sayer.push(@teen[10+@temp])
|
|
41
|
+
elsif number[1] == 0
|
|
42
|
+
if @temp != 0
|
|
43
|
+
@sayer.push(@satuan_en[@temp])
|
|
44
|
+
end
|
|
45
|
+
else
|
|
46
|
+
if @temp != 0
|
|
47
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp])
|
|
48
|
+
else
|
|
49
|
+
@sayer.push(@anomalies[number[1]*10])
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
return @sayer
|
|
53
|
+
end
|
|
44
54
|
end
|
|
45
55
|
|
|
46
56
|
def self.get_number_sayer_ratus_ribuan(number)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
@sayer = []
|
|
58
|
+
@temp = number.first
|
|
59
|
+
if number.count == 1
|
|
60
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000])
|
|
61
|
+
return @sayer
|
|
62
|
+
elsif number.count == 2
|
|
63
|
+
if number[1] == 1
|
|
64
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000])
|
|
65
|
+
else
|
|
66
|
+
if @temp != 0
|
|
67
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000])
|
|
68
|
+
else
|
|
69
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000])
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
return @sayer
|
|
73
|
+
elsif number.count == 3
|
|
74
|
+
if number.last == 0
|
|
75
|
+
else
|
|
76
|
+
if @temp != 0
|
|
77
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
78
|
+
else
|
|
79
|
+
if number[1] != 0
|
|
80
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
81
|
+
else
|
|
82
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100]).push(@anomalies[1000])
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
if number[1] == 1
|
|
87
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000])
|
|
88
|
+
elsif number[1] == 0
|
|
89
|
+
if @temp != 0
|
|
90
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000])
|
|
91
|
+
end
|
|
92
|
+
else
|
|
93
|
+
if @temp != 0
|
|
94
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000])
|
|
95
|
+
else
|
|
96
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000])
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
return @sayer
|
|
100
|
+
end
|
|
91
101
|
end
|
|
92
102
|
|
|
93
103
|
def self.get_number_sayer_ratus_jutaan(number)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
104
|
+
@sayer = []
|
|
105
|
+
@temp = number.first
|
|
106
|
+
if number.count == 1
|
|
107
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000000])
|
|
108
|
+
return @sayer
|
|
109
|
+
elsif number.count == 2
|
|
110
|
+
if number[1] == 1
|
|
111
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000000])
|
|
112
|
+
else
|
|
113
|
+
if @temp != 0
|
|
114
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000000])
|
|
115
|
+
else
|
|
116
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000000])
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
return @sayer
|
|
120
|
+
elsif number.count == 3
|
|
121
|
+
if number.last == 0
|
|
122
|
+
else
|
|
123
|
+
if @temp != 0
|
|
124
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
125
|
+
else
|
|
126
|
+
if number[1] != 0
|
|
127
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
128
|
+
else
|
|
129
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100]).push(@anomalies[1000000])
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
if number[1] == 1
|
|
134
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000000])
|
|
135
|
+
elsif number[1] == 0
|
|
136
|
+
if @temp != 0
|
|
137
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000000])
|
|
138
|
+
end
|
|
139
|
+
else
|
|
140
|
+
if @temp != 0
|
|
141
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000000])
|
|
142
|
+
else
|
|
143
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000000])
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
return @sayer
|
|
147
|
+
end
|
|
138
148
|
end
|
|
139
149
|
|
|
140
150
|
def self.get_number_sayer_ratus_milyaran(number)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
151
|
+
@sayer = []
|
|
152
|
+
@temp = number.first
|
|
153
|
+
if number.count == 1
|
|
154
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000000000])
|
|
155
|
+
return @sayer
|
|
156
|
+
elsif number.count == 2
|
|
157
|
+
if number[1] == 1
|
|
158
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000000000])
|
|
159
|
+
else
|
|
160
|
+
if @temp != 0
|
|
161
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000000000])
|
|
162
|
+
else
|
|
163
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000000000])
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
return @sayer
|
|
167
|
+
elsif number.count == 3
|
|
168
|
+
if number.last == 0
|
|
169
|
+
else
|
|
170
|
+
if @temp != 0
|
|
171
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
172
|
+
else
|
|
173
|
+
if number[1] != 0
|
|
174
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
175
|
+
else
|
|
176
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100]).push(@anomalies[1000000000])
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
if number[1] == 1
|
|
181
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000000000])
|
|
182
|
+
elsif number[1] == 0
|
|
183
|
+
if @temp != 0
|
|
184
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000000000])
|
|
185
|
+
end
|
|
186
|
+
else
|
|
187
|
+
if @temp != 0
|
|
188
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000000000])
|
|
189
|
+
else
|
|
190
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000000000])
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
return @sayer
|
|
194
|
+
end
|
|
185
195
|
end
|
|
186
196
|
|
|
187
197
|
def self.get_number_sayer_ratus_triliunan(number)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
198
|
+
@sayer = []
|
|
199
|
+
@temp = number.first
|
|
200
|
+
if number.count == 1
|
|
201
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000000000000])
|
|
202
|
+
return @sayer
|
|
203
|
+
elsif number.count == 2
|
|
204
|
+
if number[1] == 1
|
|
205
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000000000000])
|
|
206
|
+
else
|
|
207
|
+
if @temp != 0
|
|
208
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000000000000])
|
|
209
|
+
else
|
|
210
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000000000000])
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
return @sayer
|
|
214
|
+
elsif number.count == 3
|
|
215
|
+
if number.last == 0
|
|
216
|
+
else
|
|
217
|
+
if @temp != 0
|
|
218
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
219
|
+
else
|
|
220
|
+
if number[1] != 0
|
|
221
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100])
|
|
222
|
+
else
|
|
223
|
+
@sayer.push(@satuan_en[number.last]).push(@anomalies[100]).push(@anomalies[1000000000000])
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
if number[1] == 1
|
|
228
|
+
@sayer.push(@teen[10+@temp]).push(@anomalies[1000000000000])
|
|
229
|
+
elsif number[1] == 0
|
|
230
|
+
if @temp != 0
|
|
231
|
+
@sayer.push(@satuan_en[@temp]).push(@anomalies[1000000000000])
|
|
232
|
+
end
|
|
233
|
+
else
|
|
234
|
+
if @temp != 0
|
|
235
|
+
@sayer.push(@anomalies[number[1]*10]).push(@satuan_en[@temp]).push(@anomalies[1000000000000])
|
|
236
|
+
else
|
|
237
|
+
@sayer.push(@anomalies[number[1]*10]).push(@anomalies[1000000000000])
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
return @sayer
|
|
241
|
+
end
|
|
232
242
|
end
|
|
233
243
|
|
|
234
244
|
def self.check_nol(saying)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
245
|
+
if saying == ["zero"] or saying == "zero"
|
|
246
|
+
return ["zero"]
|
|
247
|
+
end
|
|
248
|
+
@check = saying.split(@satuan_en.first)
|
|
249
|
+
if @check.count < 1
|
|
250
|
+
return @check
|
|
251
|
+
else
|
|
252
|
+
return @check.map!{ |element| element.gsub("zero", "").gsub(" ", " ") }
|
|
253
|
+
end
|
|
244
254
|
end
|
|
245
255
|
|
|
246
256
|
def self.get_number_sayer_per_separator(block, number)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
@array_number = number.split("").map { |i| i.to_i }
|
|
258
|
+
if block == 0
|
|
259
|
+
get_number_sayer_ratusan(@array_number)
|
|
260
|
+
elsif block == 1
|
|
261
|
+
get_number_sayer_ratus_ribuan(@array_number)
|
|
262
|
+
elsif block == 2
|
|
263
|
+
get_number_sayer_ratus_jutaan(@array_number)
|
|
264
|
+
elsif block == 3
|
|
265
|
+
get_number_sayer_ratus_milyaran(@array_number)
|
|
266
|
+
elsif block == 4
|
|
267
|
+
get_number_sayer_ratus_triliunan(@array_number)
|
|
268
|
+
else
|
|
269
|
+
raise "exceeds the calculation function"
|
|
270
|
+
end
|
|
261
271
|
end
|
|
262
272
|
|
|
263
273
|
end
|