Class: Valvat::Checksum::MT
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
check_digit_length, #initialize, #validate
Constructor Details
This class inherits a constructor from Valvat::Checksum::Base
Instance Method Details
#check_digit ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/valvat/checksum/mt.rb', line 8 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 |