Sha256: d827c58a090455fe4bb15aa3495366fb1bebf311ac76563dbae1fd931341d399

Contents?: true

Size: 271 Bytes

Versions: 16

Compression:

Stored size: 271 Bytes

Contents

class Valvat
  module Checksum
    class FI < Base
      def check_digit
        weight = [7, 9, 10, 5, 8, 4, 2]
        chk = 11 - figures.map do |fig|
          fig * weight.shift
        end.inject(:+).modulo(11)
        chk == 11 ? 0 : chk
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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