Sha256: f8c11a543cdf3a24989c5742996392b21c5a6972c97f9a0c7b774b5a9c6d78e2
Contents?: true
Size: 310 Bytes
Versions: 4
Compression:
Stored size: 310 Bytes
Contents
class CNPJ class VerifierDigit def self.generate(numbers) index = 2 sum = numbers.reverse.reduce(0) do |sum, number| (sum + number * index).tap do index = index == 9 ? 2 : index + 1 end end mod = sum % 11 mod < 2 ? 0 : 11 - mod end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cpf_cnpj-0.3.0 | lib/cnpj/verifier_digit.rb |
cpf_cnpj-0.2.1 | lib/cnpj/verifier_digit.rb |
cpf_cnpj-0.2.0 | lib/cnpj/verifier_digit.rb |
cpf_cnpj-0.1.0 | lib/cnpj/verifier_digit.rb |