Sha256: 5dd55d89872b6d07dee5ca9577be9fbfb9620f76212542d1d61e6d417154c5ec
Contents?: true
Size: 290 Bytes
Versions: 2
Compression:
Stored size: 290 Bytes
Contents
class CPF class VerifierDigit def self.generate(numbers) modulus = numbers.size + 1 multiplied = numbers.map.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.2.0 | lib/cpf/verifier_digit.rb |
cpf_cnpj-0.1.0 | lib/cpf/verifier_digit.rb |