Class: Valvat::Checksum::LT

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/lt.rb

Instance Attribute Summary

Attributes inherited from Base

#vat

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_digitObject



6
7
8
9
10
11
# File 'lib/valvat/checksum/lt.rb', line 6

def check_digit
  base_checksum    = sum_with(0) % 11
  shifted_checksum = sum_with(2) % 11

  [base_checksum, shifted_checksum, 0].find { |checksum| checksum % 11 != 10 }
end