Sha256: 4de364d974d91ebd051968e940f05e38394e3490089a2f81d4b1f185afcb8dfc
Contents?: true
Size: 578 Bytes
Versions: 14
Compression:
Stored size: 578 Bytes
Contents
# frozen_string_literal: true 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
14 entries across 14 versions & 1 rubygems