Sha256: 6491fa33b24f5cdf3bd5aebf4884c2cbe4430f92b3fea904576cd52e43010b5e

Contents?: true

Size: 311 Bytes

Versions: 16

Compression:

Stored size: 311 Bytes

Contents

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

16 entries across 16 versions & 1 rubygems

Version Path
valvat-1.0.1 lib/valvat/checksum/dk.rb
valvat-1.0.0 lib/valvat/checksum/dk.rb
valvat-0.9.1 lib/valvat/checksum/dk.rb
valvat-0.9.0 lib/valvat/checksum/dk.rb
valvat-0.8.2 lib/valvat/checksum/dk.rb
valvat-0.8.1 lib/valvat/checksum/dk.rb
valvat-0.8.0 lib/valvat/checksum/dk.rb
valvat-0.7.4 lib/valvat/checksum/dk.rb
valvat-0.7.3 lib/valvat/checksum/dk.rb
valvat-0.7.2 lib/valvat/checksum/dk.rb
valvat-0.7.1 lib/valvat/checksum/dk.rb
valvat-0.7.0 lib/valvat/checksum/dk.rb
valvat-0.6.11 lib/valvat/checksum/dk.rb
valvat-0.6.10 lib/valvat/checksum/dk.rb
valvat-0.6.9 lib/valvat/checksum/dk.rb
valvat-0.6.8 lib/valvat/checksum/dk.rb