say_number 0.1.2 → 0.1.3

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: da0a58a4ade67a8b5eb18e39b0770356d9946851
4
- data.tar.gz: 462be3472d3f922baed400e153c965dfdb9d1c67
3
+ metadata.gz: f7f4289de09f87648cfdaff32a01d29d8ae32b3d
4
+ data.tar.gz: b10607d4b7ad4c8866832c21160046322c896872
5
5
  SHA512:
6
- metadata.gz: d4a0720b13f8dbd870c4084491ea81a34be57377bd3062edd3a71d5ba5c42f8ca581fec73fe16207aa3f8b525f29e682f307fa3e1349f8275c049790f34d2ffc
7
- data.tar.gz: e4411e075d2325a9f1f018424c2dce7577c74510fde73bc5c20d6cc1904cccb2b88a83f540209dc05ed178081eb823d8a1ba48011688ee19794e10601809d6fe
6
+ metadata.gz: 3722e9dd04ff609a8cbf2b1ab4db82e8c2cfa77e023ebcd7aa7da056d6f45c8517bc2a9e2baabacb523ab7abbc0fc063fea7aca9be10693a933f488dae0d66fc
7
+ data.tar.gz: 1f561eb16f891a210642f8677009d7931a7592a7352b1f4793523cd0e9efb16f22ec4601fdcfcc652e91ab0edd265abb842831a94c5aaa2c67338c66851bb68a
data/README.md CHANGED
@@ -3,18 +3,18 @@
3
3
  Welcome to SayNumber, this is my first gem, I know there is a lot that need to be improve, so let me know if you have any suggestion.
4
4
 
5
5
  SayNumber is a simple gem that say the given number
6
+
6
7
  (SayNumber adalah gem untuk menggenerate #terbilang dari angka yang diinginkan)
7
8
 
8
9
  in example : 123400 => "seratus dua puluh tiga ribu empat ratus"
10
+
9
11
  for now it can only in Indonesian, but I will update it soon and add English
10
12
 
11
13
  ## Installation
12
14
 
13
15
  Add this line to your application's Gemfile:
14
16
 
15
- ```ruby
16
- gem 'say_number'
17
- ```
17
+ gem 'say_number'
18
18
 
19
19
  And then execute:
20
20
 
@@ -27,12 +27,14 @@ Or install it yourself as:
27
27
  ## Usage
28
28
 
29
29
  Simple, just call it SayNumber.say()
30
+
30
31
  example :
31
- ```ruby
32
- SayNumber.say(100320)
33
- ```
32
+
33
+ SayNumber.say(100320)
34
+
34
35
  it will generate
35
- "seratus ribu tiga ratus dua puluh"
36
+
37
+ "seratus ribu tiga ratus dua puluh"
36
38
 
37
39
  ## Contributing
38
40
 
@@ -41,3 +43,7 @@ it will generate
41
43
  3. Commit your changes (`git commit -am 'Add some feature'`)
42
44
  4. Push to the branch (`git push origin my-new-feature`)
43
45
  5. Create a new Pull Request
46
+
47
+ ## Suggestion
48
+
49
+ if you have suggestion or request, you can send me an email to ferydjzz@gmail.com
@@ -1,7 +1,7 @@
1
1
  class Indonesia
2
2
  def self.initialize_sayer
3
3
  @satuan_id = ["nol", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan"]
4
- @anomalies = {10=>"sepuluh", 11=>"sebelas", 100=>"seratus", 1000=>"seribu" }
4
+ @anomalies = {10=>"sepuluh", 11=>"sebelas", 100=>"seratus", 1000=>"seribu", 1000000=>"juta", 1000000000=>"miliyar", 1000000000000=>"triliun" }
5
5
  end
6
6
 
7
7
  def self.get_number_sayer_ratusan(number)
@@ -130,19 +130,19 @@ class Indonesia
130
130
  @sayer = []
131
131
  @temp = number.first
132
132
  if number.count == 1
133
- return @sayer.push(@satuan_id[@temp]).push("juta")
133
+ return @sayer.push(@satuan_id[@temp]).push(@anomalies[1000000])
134
134
  elsif number.count == 2
135
135
  if number[1] == 1
136
136
  if @temp == 1 or @temp == 0
137
- @sayer.push(@anomalies[10+@temp]).push("juta")
137
+ @sayer.push(@anomalies[10+@temp]).push(@anomalies[1000000])
138
138
  else
139
- @sayer.push(@satuan_id[@temp]).push("belas").push("juta")
139
+ @sayer.push(@satuan_id[@temp]).push("belas").push(@anomalies[1000000])
140
140
  end
141
141
  else
142
142
  if @temp != 0
143
- @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push("juta")
143
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push(@anomalies[1000000])
144
144
  else
145
- @sayer.push(@satuan_id[number[1]]).push("puluh").push("juta")
145
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@anomalies[1000000])
146
146
  end
147
147
  end
148
148
  return @sayer
@@ -154,7 +154,7 @@ class Indonesia
154
154
  if number[1] != 0
155
155
  @sayer.push(@anomalies[100])
156
156
  else
157
- @sayer.push(@anomalies[100]).push("juta")
157
+ @sayer.push(@anomalies[100]).push(@anomalies[1000000])
158
158
  end
159
159
  end
160
160
  else
@@ -166,7 +166,7 @@ class Indonesia
166
166
  if number[1] != 0
167
167
  @sayer.push(@satuan_id[number.last]).push("ratus")
168
168
  else
169
- @sayer.push(@satuan_id[number.last]).push("ratus").push("juta")
169
+ @sayer.push(@satuan_id[number.last]).push("ratus").push(@anomalies[1000000])
170
170
  end
171
171
 
172
172
  end
@@ -174,19 +174,19 @@ class Indonesia
174
174
  end
175
175
  if number[1] == 1
176
176
  if @temp == 1 or @temp == 0
177
- @sayer.push(@anomalies[10+@temp]).push("juta")
177
+ @sayer.push(@anomalies[10+@temp]).push(@anomalies[1000000])
178
178
  else
179
- @sayer.push(@satuan_id[@temp]).push("belas").push("juta")
179
+ @sayer.push(@satuan_id[@temp]).push("belas").push(@anomalies[1000000])
180
180
  end
181
181
  elsif number[1] == 0
182
182
  if @temp != 0
183
- @sayer.push(@satuan_id[@temp]).push("juta")
183
+ @sayer.push(@satuan_id[@temp]).push(@anomalies[1000000])
184
184
  end
185
185
  else
186
186
  if @temp != 0
187
- @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push("juta")
187
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push(@anomalies[1000000])
188
188
  else
189
- @sayer.push(@satuan_id[number[1]]).push("puluh").push("juta")
189
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@anomalies[1000000])
190
190
  end
191
191
  end
192
192
  return @sayer
@@ -197,19 +197,19 @@ class Indonesia
197
197
  @sayer = []
198
198
  @temp = number.first
199
199
  if number.count == 1
200
- return @sayer.push(@satuan_id[@temp]).push("milyar")
200
+ return @sayer.push(@satuan_id[@temp]).push(@anomalies[1000000000])
201
201
  elsif number.count == 2
202
202
  if number[1] == 1
203
203
  if @temp == 1 or @temp == 0
204
- @sayer.push(@anomalies[10+@temp]).push("milyar")
204
+ @sayer.push(@anomalies[10+@temp]).push(@anomalies[1000000000])
205
205
  else
206
- @sayer.push(@satuan_id[@temp]).push("belas").push("milyar")
206
+ @sayer.push(@satuan_id[@temp]).push("belas").push(@anomalies[1000000000])
207
207
  end
208
208
  else
209
209
  if @temp != 0
210
- @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push("milyar")
210
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push(@anomalies[1000000000])
211
211
  else
212
- @sayer.push(@satuan_id[number[1]]).push("puluh").push("milyar")
212
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@anomalies[1000000000])
213
213
  end
214
214
  end
215
215
  return @sayer
@@ -221,7 +221,7 @@ class Indonesia
221
221
  if number[1] != 0
222
222
  @sayer.push(@anomalies[100])
223
223
  else
224
- @sayer.push(@anomalies[100]).push("milyar")
224
+ @sayer.push(@anomalies[100]).push(@anomalies[1000000000])
225
225
  end
226
226
  end
227
227
  else
@@ -233,7 +233,7 @@ class Indonesia
233
233
  if number[1] != 0
234
234
  @sayer.push(@satuan_id[number.last]).push("ratus")
235
235
  else
236
- @sayer.push(@satuan_id[number.last]).push("ratus").push("milyar")
236
+ @sayer.push(@satuan_id[number.last]).push("ratus").push(@anomalies[1000000000])
237
237
  end
238
238
 
239
239
  end
@@ -241,19 +241,86 @@ class Indonesia
241
241
  end
242
242
  if number[1] == 1
243
243
  if @temp == 1 or @temp == 0
244
- @sayer.push(@anomalies[10+@temp]).push("milyar")
244
+ @sayer.push(@anomalies[10+@temp]).push(@anomalies[1000000000])
245
245
  else
246
- @sayer.push(@satuan_id[@temp]).push("belas").push("milyar")
246
+ @sayer.push(@satuan_id[@temp]).push("belas").push(@anomalies[1000000000])
247
247
  end
248
248
  elsif number[1] == 0
249
249
  if @temp != 0
250
- @sayer.push(@satuan_id[@temp]).push("milyar")
250
+ @sayer.push(@satuan_id[@temp]).push(@anomalies[1000000000])
251
251
  end
252
252
  else
253
253
  if @temp != 0
254
- @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push("milyar")
254
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push(@anomalies[1000000000])
255
255
  else
256
- @sayer.push(@satuan_id[number[1]]).push("puluh").push("milyar")
256
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@anomalies[1000000000])
257
+ end
258
+ end
259
+ return @sayer
260
+ end
261
+ end
262
+
263
+ def self.get_number_sayer_ratus_triliunan(number)
264
+ @sayer = []
265
+ @temp = number.first
266
+ if number.count == 1
267
+ return @sayer.push(@satuan_id[@temp]).push(@anomalies[1000000000000])
268
+ elsif number.count == 2
269
+ if number[1] == 1
270
+ if @temp == 1 or @temp == 0
271
+ @sayer.push(@anomalies[10+@temp]).push(@anomalies[1000000000000])
272
+ else
273
+ @sayer.push(@satuan_id[@temp]).push("belas").push(@anomalies[1000000000000])
274
+ end
275
+ else
276
+ if @temp != 0
277
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push(@anomalies[1000000000000])
278
+ else
279
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@anomalies[1000000000000])
280
+ end
281
+ end
282
+ return @sayer
283
+ elsif number.count == 3
284
+ if number.last == 1
285
+ if @temp != 0
286
+ @sayer.push(@anomalies[100])
287
+ else
288
+ if number[1] != 0
289
+ @sayer.push(@anomalies[100])
290
+ else
291
+ @sayer.push(@anomalies[100]).push(@anomalies[1000000000000])
292
+ end
293
+ end
294
+ else
295
+ if number.last == 0
296
+ else
297
+ if @temp != 0
298
+ @sayer.push(@satuan_id[number.last]).push("ratus")
299
+ else
300
+ if number[1] != 0
301
+ @sayer.push(@satuan_id[number.last]).push("ratus")
302
+ else
303
+ @sayer.push(@satuan_id[number.last]).push("ratus").push(@anomalies[1000000000000])
304
+ end
305
+
306
+ end
307
+ end
308
+ end
309
+ if number[1] == 1
310
+ if @temp == 1 or @temp == 0
311
+ @sayer.push(@anomalies[10+@temp]).push(@anomalies[1000000000000])
312
+ else
313
+ @sayer.push(@satuan_id[@temp]).push("belas").push(@anomalies[1000000000000])
314
+ end
315
+ elsif number[1] == 0
316
+ if @temp != 0
317
+ @sayer.push(@satuan_id[@temp]).push(@anomalies[1000000000000])
318
+ end
319
+ else
320
+ if @temp != 0
321
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@satuan_id[@temp]).push(@anomalies[1000000000000])
322
+ else
323
+ @sayer.push(@satuan_id[number[1]]).push("puluh").push(@anomalies[1000000000000])
257
324
  end
258
325
  end
259
326
  return @sayer
@@ -283,6 +350,8 @@ class Indonesia
283
350
  get_number_sayer_ratus_jutaan(@array_number)
284
351
  elsif block == 3
285
352
  get_number_sayer_ratus_milyaran(@array_number)
353
+ elsif block == 4
354
+ get_number_sayer_ratus_triliunan(@array_number)
286
355
  else
287
356
  raise "exceeds the calculation function"
288
357
  end
@@ -1,3 +1,3 @@
1
1
  module SayNumber
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/say_number.rb CHANGED
@@ -31,7 +31,7 @@ module SayNumber
31
31
  @saying.push(Indonesia.get_number_sayer_per_separator(i, @array[i]))
32
32
  end
33
33
  @saying = @saying.reverse.join(" ")
34
- return Indonesia.check_nol(@saying).first
34
+ return Indonesia.check_nol(@saying).first.strip
35
35
  else
36
36
  raise "Unknown Language"
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: say_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fery Japminto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-26 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler