Sha256: 9c4e02374a290fd9b474a1e249c779ce53d93f36c1f1cc4f36d6ba55568a0ef1

Contents?: true

Size: 480 Bytes

Versions: 6

Compression:

Stored size: 480 Bytes

Contents

require_relative 'document'

module BrDocuments
  module CnpjCpf
    class Cnpj
      include Document

      private

      def format_regex
        /^(\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2})$|^(\d{14})$/
      end

      def weights_for_digital_check
        [[5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2], [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]]
      end

      def format_number
        @number.sub(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '\\1.\\2.\\3/\\4-\\5')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
br_documents-0.2.5 lib/br_documents/cnpj_cpf/cnpj.rb
br_documents-0.2.4 lib/br_documents/cnpj_cpf/cnpj.rb
br_documents-0.2.3 lib/br_documents/cnpj_cpf/cnpj.rb
br_documents-0.2.2 lib/br_documents/cnpj_cpf/cnpj.rb
br_documents-0.2.1 lib/br_documents/cnpj_cpf/cnpj.rb
br_documents-0.2.0 lib/br_documents/cnpj_cpf/cnpj.rb