Sha256: 4c61c456720bcbd798c99b55e5c01da176932697543168e65d38fa277ffd1181
Contents?: true
Size: 468 Bytes
Versions: 3
Compression:
Stored size: 468 Bytes
Contents
module MRZ class CheckDigit def check_calc(str) str = str.strip.upcase values = str.chars.map do |char| case char when '<' 0 when 'A'..'Z' char.ord - 65 + 10 when '0'..'9' char.ord - 48 else raise "Unexpected character '#{char}'" end end return (values.zip([7,3,1].cycle).map{|(v,w)| v * w}.reduce(:+) % 10).to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
verified-1.3.3 | lib/verified/parser/mrz/check_digit.rb |
verified-1.3.1 | lib/verified/parser/mrz/check_digit.rb |
verified-1.3.0 | lib/verified/parser/mrz/check_digit.rb |