Sha256: 8255e1fe9dec7e7ad2a28a3ea4bcdaaf23fb2f274d78f3e581bf1013706858e7

Contents?: true

Size: 269 Bytes

Versions: 14

Compression:

Stored size: 269 Bytes

Contents

# frozen_string_literal: true

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

14 entries across 14 versions & 1 rubygems

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