Sha256: 4ed94af8310be01c0fba89c98669de16eafe87085747bf548bf48bef46be89e7
Contents?: true
Size: 376 Bytes
Versions: 14
Compression:
Stored size: 376 Bytes
Contents
# frozen_string_literal: true class Valvat module Checksum class DE < Base M = 10 N = 11 def check_digit prod = M figures.each do |fig| sum = (prod + fig).modulo(M) sum = M if sum.zero? prod = (2 * sum).modulo(N) end chk = N - prod chk == 10 ? 0 : chk end end end end
Version data entries
14 entries across 14 versions & 1 rubygems