Sha256: 991613984a5fc4651d0062f58d488f0e68365f819e04d32efb369bf7309f2e72

Contents?: true

Size: 325 Bytes

Versions: 1

Compression:

Stored size: 325 Bytes

Contents

module Vindetta
  class Calculator
    MAP = %w(0 1 2 3 4 5 6 7 8 9 X)
    WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]

    def self.check_digit(vin)
      sum = Transliterator
        .vin(vin)
        .zip(WEIGHTS)
        .reduce(0) {|sum, (a, b)| sum + (a * b) }

      MAP[sum % 11]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vindetta-0.17.1 lib/vindetta/calculator.rb