Sha256: 837a6a64257816e14b8c02355904c0b85189c6a80ec8aabf324ca4278ff1ec60

Contents?: true

Size: 446 Bytes

Versions: 7

Compression:

Stored size: 446 Bytes

Contents

require_relative "document"

module BrDocuments
  module CnpjCpf
    class Cpf
      include Document

      private

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
br_documents-0.1.3 lib/br_documents/cnpj_cpf/cpf.rb
br_documents-0.1.2 lib/br_documents/cnpj_cpf/cpf.rb
br_documents-0.1.1 lib/br_documents/cnpj_cpf/cpf.rb
br_documents-0.1.0 lib/br_documents/cnpj_cpf/cpf.rb
br_documents-0.0.15 lib/br_documents/cnpj_cpf/cpf.rb
br_documents-0.0.14 lib/br_documents/cnpj_cpf/cpf.rb
br_documents-0.0.13 lib/br_documents/cnpj_cpf/cpf.rb