Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/takeshiToolv1.rb
Instance Method Summary collapse
Instance Method Details
#isTwID? ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/takeshiToolv1.rb', line 10 def isTwID? a_to_n = (10..17).to_a a_to_n.push 34 a_to_n += (18..22).to_a a_to_n.push 35 a_to_n += (23..29).to_a a_to_n.push 32 a_to_n += (30..31).to_a a_to_n.push 33 place_n = a_to_n[self[0].ord-'A'.ord] sum = 0 sum += place_n/10 + (place_n%10)*9 tmp = 8 1.upto(8) do |i| sum += (self[i].ord - '0'.ord)*tmp tmp -= 1 end sum += (self[9].ord - '0'.ord) sum%10 == 0 end |