Class: Valvat::Checksum::PL

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/pl.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/pl.rb', line 6

def check_digit
  weight = [6, 5, 7, 2, 3, 4, 5, 6, 7]
  figures.map do |fig|
    fig * weight.shift
  end.inject(:+).modulo(11)
end