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

Version Path
valvat-1.4.4 lib/valvat/checksum/de.rb
valvat-1.4.3 lib/valvat/checksum/de.rb
valvat-1.4.2 lib/valvat/checksum/de.rb
valvat-1.4.1 lib/valvat/checksum/de.rb
valvat-1.4.0 lib/valvat/checksum/de.rb
valvat-1.3.0 lib/valvat/checksum/de.rb
valvat-1.2.1 lib/valvat/checksum/de.rb
valvat-1.2.0 lib/valvat/checksum/de.rb
valvat-1.1.5 lib/valvat/checksum/de.rb
valvat-1.1.4 lib/valvat/checksum/de.rb
valvat-1.1.3 lib/valvat/checksum/de.rb
valvat-1.1.2 lib/valvat/checksum/de.rb
valvat-1.1.1 lib/valvat/checksum/de.rb
valvat-1.1.0 lib/valvat/checksum/de.rb