Sha256: 4b630a2263c648472611eca4a375461dffc2f1348f406645f10c95fc22fb4cd0

Contents?: true

Size: 446 Bytes

Versions: 6

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

6 entries across 6 versions & 1 rubygems

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