Sha256: 653e9098af0a0051199d684e68a717e11146cba1f7875603dbd9fb63cca43a0d
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 Bytes
Contents
require "takami2/version" class String def is_valid_taiwanese_id? cities = { :A => '10', :B => '11', :C => '12', :D => '13', :E => '14', :F => '15', :G => '16', :H => '17', :I => '34', :J => '18', :K => '19', :L => '20', :M => '21', :N => '22', :O => '35', :P => '23', :Q => '24', :R => '25', :S => '26', :T => '27', :U => '28', :V => '29', :W => '32', :X => '30', :Y => '31', :Z => '33', } id_array = self.upcase.split('') special = cities[id_array.first.to_sym][0].to_i * 1 + cities[id_array.first.to_sym][1].to_i * 9 sum = special + id_array[1].to_i * 8 + id_array[2].to_i * 7 + id_array[3].to_i * 6 + id_array[4].to_i * 5 + id_array[5].to_i * 4 + id_array[6].to_i * 3 + id_array[7].to_i * 2 + id_array[8].to_i * 1 + id_array[9].to_i return sum % 10 == 0 end end module Takami2 def is_ruby_awesome? "YES" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
takami2-0.0.3 | lib/takami2.rb |