Sha256: d338ed5299240f5a59000c4d30c07440bb20e55a83d035b551a058a97e0915ce

Contents?: true

Size: 596 Bytes

Versions: 5

Compression:

Stored size: 596 Bytes

Contents

module Brid
  @@detect_between = {
    :cpf            => Brid::CPF,
    :cnpj           => Brid::CNPJ,
    :titulo_eleitor => Brid::TituloEleitor,
    :pis            => Brid::PIS
  } 

  def self.detect number, between = [:cpf, :cnpj, :titulo_eleitor, :pis]
    id = [*between].each do |class_symbol|
      break unless class_symbol

      class_constant  = @@detect_between[class_symbol]
      begin
        _number         = class_constant.new number
        break _number  if _number and _number.valid?
      rescue ArgumentError
      end
    end

    id if id.kind_of? GenericID
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
brid-0.2.1 lib/brid/detector.rb
brid-0.2.0 lib/brid/detector.rb
brid-0.1.3 lib/brid/detector.rb
brid-0.1.2 lib/brid/detector.rb
brid-0.1.1 lib/brid/detector.rb