Class: Valvat::Checksum::DE
Constant Summary collapse
- M =
10- N =
11
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
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/valvat/checksum/de.rb', line 9 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 |