Sha256: ed1849dea5e053b5fca8343a8b4ce2c228d3f082b0a475a18abec18a563322b7

Contents?: true

Size: 238 Bytes

Versions: 3

Compression:

Stored size: 238 Bytes

Contents

class CNPJ
  class Formatter
    def self.format(number)
      strip(number).gsub(/\A(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})\Z/, "\\1.\\2.\\3/\\4-\\5")
    end

    def self.strip(number)
      number.to_s.gsub(/[^\d]/, "")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cpf_cnpj-0.2.1 lib/cnpj/formatter.rb
cpf_cnpj-0.2.0 lib/cnpj/formatter.rb
cpf_cnpj-0.1.0 lib/cnpj/formatter.rb