Sha256: 55a652fa1323698cd2a7aa91191bc6cb1d577b62e64671c52140c3217ceb0c42
Contents?: true
Size: 403 Bytes
Versions: 6
Compression:
Stored size: 403 Bytes
Contents
module BrDocuments module Commons module Mod11 def generate_check_digit(values, weights) sum = reduce_weights(values, weights) mod = sum % 11 mod < 2 ? 0 : (11 - mod) end def reduce_weights(values, weights) sum = 0 weights.each_index do |i| sum += weights[i] * values[i].to_i end sum end end end end
Version data entries
6 entries across 6 versions & 1 rubygems