Sha256: 51c9da920a06bbef31ae48d08fea9094167738d04fd27f53ecef41fef0f58c4c

Contents?: true

Size: 348 Bytes

Versions: 12

Compression:

Stored size: 348 Bytes

Contents

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

12 entries across 12 versions & 1 rubygems

Version Path
valvat-1.0.1 lib/valvat/checksum/mt.rb
valvat-1.0.0 lib/valvat/checksum/mt.rb
valvat-0.9.1 lib/valvat/checksum/mt.rb
valvat-0.9.0 lib/valvat/checksum/mt.rb
valvat-0.8.2 lib/valvat/checksum/mt.rb
valvat-0.8.1 lib/valvat/checksum/mt.rb
valvat-0.8.0 lib/valvat/checksum/mt.rb
valvat-0.7.4 lib/valvat/checksum/mt.rb
valvat-0.7.3 lib/valvat/checksum/mt.rb
valvat-0.7.2 lib/valvat/checksum/mt.rb
valvat-0.7.1 lib/valvat/checksum/mt.rb
valvat-0.7.0 lib/valvat/checksum/mt.rb