aName 0.0.2 → 0.0.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.
Files changed (3) hide show
  1. data/lib/aName.rb +31 -3
  2. data/lib/aName/version.rb +1 -1
  3. metadata +1 -1
data/lib/aName.rb CHANGED
@@ -1,7 +1,35 @@
1
1
  require "aName/version"
2
2
 
3
- module AName
4
- def Is_ruby_useful?
5
- 'yes'
3
+ class String
4
+ module is_valid_taiwanese_id?
5
+ cities = {
6
+ :A => '10', :B => '11', :C => '12', :D => '13',
7
+ :E => '14', :F => '15', :G => '16', :H => '17',
8
+ :I => '34', :J => '18', :K => '19', :L => '20',
9
+ :M => '21', :N => '22', :O => '35', :P => '23',
10
+ :Q => '24', :R => '25', :S => '26', :T => '27',
11
+ :U => '28', :V => '29', :W => '32', :X => '30',
12
+ :Y => '31', :Z => '33',
13
+ }
14
+
15
+ id_array = self.upcase.split('')
16
+
17
+ special = cities[id_array.first.to_sym][0].to_i * 1 + cities[id_array.first.to_sym][1].to_i * 9
18
+ sum =
19
+ special +
20
+ id_array[1].to_i * 8 +
21
+ id_array[2].to_i * 7 +
22
+ id_array[3].to_i * 6 +
23
+ id_array[4].to_i * 5 +
24
+ id_array[5].to_i * 4 +
25
+ id_array[6].to_i * 3 +
26
+ id_array[7].to_i * 2 +
27
+ id_array[8].to_i * 1 +
28
+ id_array[9].to_i
29
+
30
+ return sum % 10 == 0
6
31
  end
7
32
  end
33
+
34
+ module aName
35
+ end
data/lib/aName/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AName
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: aName
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: