Sha256: c686d4b5f97de2214377b7aca8584212c2040ced4d07fc2fd9264fdfa0d61e52

Contents?: true

Size: 447 Bytes

Versions: 16

Compression:

Stored size: 447 Bytes

Contents

# frozen_string_literal: true

class Valvat
  module Checksum
    class CY < Base
      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

      def given_check_digit
        given_check_digit_str.downcase
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
valvat-2.0.1 lib/valvat/checksum/cy.rb
valvat-2.0.0 lib/valvat/checksum/cy.rb
valvat-1.4.4 lib/valvat/checksum/cy.rb
valvat-1.4.3 lib/valvat/checksum/cy.rb
valvat-1.4.2 lib/valvat/checksum/cy.rb
valvat-1.4.1 lib/valvat/checksum/cy.rb
valvat-1.4.0 lib/valvat/checksum/cy.rb
valvat-1.3.0 lib/valvat/checksum/cy.rb
valvat-1.2.1 lib/valvat/checksum/cy.rb
valvat-1.2.0 lib/valvat/checksum/cy.rb
valvat-1.1.5 lib/valvat/checksum/cy.rb
valvat-1.1.4 lib/valvat/checksum/cy.rb
valvat-1.1.3 lib/valvat/checksum/cy.rb
valvat-1.1.2 lib/valvat/checksum/cy.rb
valvat-1.1.1 lib/valvat/checksum/cy.rb
valvat-1.1.0 lib/valvat/checksum/cy.rb