ttutrygem 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,35 @@ require "ttutrygem/version"
2
2
 
3
3
  module Ttutrygem
4
4
  # Your code goes here...
5
- def is_ruby_ok?
6
- "YES"
7
- end
5
+ class String
6
+ def is_valid_taiwanese_id?
7
+ cities = {
8
+ :A => '10', :B => '11', :C => '12', :D => '13',
9
+ :E => '14', :F => '15', :G => '16', :H => '17',
10
+ :I => '34', :J => '18', :K => '19', :L => '20',
11
+ :M => '21', :N => '22', :O => '35', :P => '23',
12
+ :Q => '24', :R => '25', :S => '26', :T => '27',
13
+ :U => '28', :V => '29', :W => '32', :X => '30',
14
+ :Y => '31', :Z => '33',
15
+ }
16
+
17
+ id_array = self.upcase.split('')
18
+
19
+ special = cities[id_array.first.to_sym][0].to_i + cities[id_array.first.to_sym][1].to_i * 9
20
+ sum =
21
+ special +
22
+ id_array[1].to_i * 8 +
23
+ id_array[2].to_i * 7 +
24
+ id_array[3].to_i * 6 +
25
+ id_array[4].to_i * 5 +
26
+ id_array[5].to_i * 4 +
27
+ id_array[6].to_i * 3 +
28
+ id_array[7].to_i * 2 +
29
+ id_array[8].to_i * 1 +
30
+ id_array[9].to_i
31
+
32
+ sum % 10 == 0
33
+
34
+ end
35
+ end
8
36
  end
@@ -1,3 +1,3 @@
1
1
  module Ttutrygem
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttutrygem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: