Sha256: 1efd0bf564f0efe14178c809e6db9bcb4f058ec9b9707c2c3bd1aee62e31cb35

Contents?: true

Size: 468 Bytes

Versions: 23

Compression:

Stored size: 468 Bytes

Contents

class TaxIdBr
  attr_reader :document_type, :formatted
  def initialize tax_id
    create_document tax_id
  end

  def valid?
    @valid
  end

  private

  def create_document tax_id
    cpf = CPF.new(tax_id)
    cnpj = CNPJ.new(tax_id)
    @valid = true
    if cpf.valid?
      @document_type = :cpf
      @formatted = cpf.formatted
    elsif cnpj.valid?
      @document_type = :cnpj
      @formatted = cnpj.formatted
    else
      @valid = false
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
solidus_brazilian_adaptations-1.4.0 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.3.3 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.3.2 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.3.1 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.3.0 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.2.0 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.10 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.9 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.8 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.7 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.6 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.5 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.4 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.3 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.2 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.1 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.1.0 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.0.9 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.0.8 app/models/tax_id_br.rb
solidus_brazilian_adaptations-1.0.7 app/models/tax_id_br.rb