Sha256: 748edf68c6cce1e8933963a7567681ab69b7b007883b736a4d02e7e5e1e37159
Contents?: true
Size: 547 Bytes
Versions: 12
Compression:
Stored size: 547 Bytes
Contents
class Valvat module Checksum class LT < Base def check_digit base_checksum = sum_with(0) % 11 shifted_checksum = sum_with(2) % 11 [base_checksum, shifted_checksum, 0].find { |checksum| checksum % 11 != 10 } end private def sum_with(offset) sum_figures_by do |digit, index| multi_digit_multiplier = figures.size - index + offset digit * (multi_digit_multiplier > 9 ? multi_digit_multiplier % 9 : multi_digit_multiplier) end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems