Sha256: 0ac5eacfc8c24af5e3f4f7ad80b2550960f9de63b49ec1823bdb632c0533a505

Contents?: true

Size: 343 Bytes

Versions: 14

Compression:

Stored size: 343 Bytes

Contents

# frozen_string_literal: true

class Valvat
  module Checksum
    class DK < Base
      check_digit_length 0

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

      def given_check_digit
        0
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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