class Valvat::Checksum::FR
Constants
- ALPHABET
the valid characters for the first two digits (O and I are missing)
- NUMERIC
Public Instance Methods
validate()
click to toggle source
Calls superclass method
Valvat::Checksum::Base#validate
# File lib/valvat/checksum/fr.rb, line 10 def validate return super if str_wo_country[0..1] =~ NUMERIC check = alt_check_digit (str_wo_country[2..].to_i + 1 + (check / 11)) % 11 == check % 11 end
Private Instance Methods
alt_check_digit()
click to toggle source
# File lib/valvat/checksum/fr.rb, line 29 def alt_check_digit first_is_numeric = str_wo_country[0] =~ NUMERIC (ALPHABET.index(str_wo_country[0]) * (first_is_numeric ? 24 : 34)) + ALPHABET.index(str_wo_country[1]) - (first_is_numeric ? 10 : 100) end
check_digit()
click to toggle source
# File lib/valvat/checksum/fr.rb, line 20 def check_digit siren = str_wo_country[2..].to_i (12 + ((3 * siren) % 97)) % 97 end
given_check_digit()
click to toggle source
# File lib/valvat/checksum/fr.rb, line 25 def given_check_digit str_wo_country[0..1].to_i end