Sha256: 0c5446e34d56b007d9611de596150afdf50a48f4c8cd22145990aef237007fa8

Contents?: true

Size: 264 Bytes

Versions: 9

Compression:

Stored size: 264 Bytes

Contents

require 'valvat/checksum'

class Valvat
  module Checksum
    class PL < Base
      def check_digit
        weight = [6, 5, 7, 2, 3, 4, 5, 6, 7]
        figures.map do |fig|
          fig * weight.shift
        end.inject(:+).modulo(11)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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