Sha256: c3df31c4596440a5217546cb18c0550421338b525747fec9f362c13a8d15db56

Contents?: true

Size: 338 Bytes

Versions: 9

Compression:

Stored size: 338 Bytes

Contents

require 'valvat/checksum'

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

9 entries across 9 versions & 1 rubygems

Version Path
valvat-0.6.7 lib/valvat/checksum/dk.rb
valvat-0.6.6 lib/valvat/checksum/dk.rb
valvat-0.6.5 lib/valvat/checksum/dk.rb
valvat-0.6.4 lib/valvat/checksum/dk.rb
valvat-0.6.3 lib/valvat/checksum/dk.rb
valvat-0.6.2 lib/valvat/checksum/dk.rb
valvat-0.6.1 lib/valvat/checksum/dk.rb
valvat-0.6.0 lib/valvat/checksum/dk.rb
valvat-0.5.0 lib/valvat/checksum/dk.rb