Class: Valvat::Checksum::HR
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
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/valvat/checksum/hr.rb', line 6 def check_digit product = 10 sum = 0 figures.each do |figure| sum = (figure + product) % 10 sum = 10 if sum.zero? product = (2 * sum) % 11 end (10 - ((product - 1) % 10)) % 10 end |