Sha256: 7fbec162f372d86e047303be89606b7bc728d07ec9ea5b766cf94a3eef8409c0

Contents?: true

Size: 379 Bytes

Versions: 14

Compression:

Stored size: 379 Bytes

Contents

# frozen_string_literal: true

class Valvat
  module Checksum
    class MT < Base
      check_digit_length 2

      def check_digit
        multipliers = [9, 8, 7, 6, 4, 3]

        sum = sum_figures_by { |digit, index| digit * multipliers[index] }

        supposed_checksum = 37 - (sum % 37)
        supposed_checksum.zero? ? 37 : supposed_checksum
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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