Class: Valvat::Checksum::CY

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/cy.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
12
13
14
# File 'lib/valvat/checksum/cy.rb', line 6

def check_digit
  odd_position_digit_values = [1, 0, 5, 7, 9, 13, 15, 17, 19, 21]

  sum = sum_figures_by do |digit, index|
    (8 - index).odd? ? odd_position_digit_values[digit] : digit
  end

  ('a'..'z').to_a[sum % 26]
end

#given_check_digitObject



16
17
18
# File 'lib/valvat/checksum/cy.rb', line 16

def given_check_digit
  given_check_digit_str.downcase
end