Sha256: e07247c695b42fba594eadb9d0c515343ed135cc8c381c21497394f616377999

Contents?: true

Size: 335 Bytes

Versions: 12

Compression:

Stored size: 335 Bytes

Contents

class Valvat
  module Checksum
    class HR < Base
      def check_digit
        product = 10
        sum     = 0

        figures.each do |figure|
          sum = (figure + product) % 10
          sum = 10 if sum.zero?
          product = (2 * sum) % 11
        end

        (10 - (product - 1) % 10) % 10
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
valvat-1.0.1 lib/valvat/checksum/hr.rb
valvat-1.0.0 lib/valvat/checksum/hr.rb
valvat-0.9.1 lib/valvat/checksum/hr.rb
valvat-0.9.0 lib/valvat/checksum/hr.rb
valvat-0.8.2 lib/valvat/checksum/hr.rb
valvat-0.8.1 lib/valvat/checksum/hr.rb
valvat-0.8.0 lib/valvat/checksum/hr.rb
valvat-0.7.4 lib/valvat/checksum/hr.rb
valvat-0.7.3 lib/valvat/checksum/hr.rb
valvat-0.7.2 lib/valvat/checksum/hr.rb
valvat-0.7.1 lib/valvat/checksum/hr.rb
valvat-0.7.0 lib/valvat/checksum/hr.rb