Sha256: 229dfefaf2e75663f6af683bb51c5b18dbd2fdf5884cd763cf6875c3d6210744
Contents?: true
Size: 295 Bytes
Versions: 2
Compression:
Stored size: 295 Bytes
Contents
class CPF class VerifierDigit def self.generate(numbers) modulus = numbers.size + 1 multiplied = numbers.map.each_with_index do |number, index| number * (modulus - index) end mod = multiplied.reduce(:+) % 11 mod < 2 ? 0 : 11 - mod end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cpf_cnpj-0.3.0 | lib/cpf/verifier_digit.rb |
cpf_cnpj-0.2.1 | lib/cpf/verifier_digit.rb |