Module: Brid
- Defined in:
- lib/brid/ids/cpf.rb,
lib/brid/ids/pis.rb,
lib/brid/version.rb,
lib/brid/detector.rb,
lib/brid/ids/cnpj.rb,
lib/brid/ids/cred_card.rb,
lib/brid/ids/titulo_eleitor.rb
Defined Under Namespace
Classes: CNPJ, CPF, CredCard, PIS, TituloEleitor
Constant Summary collapse
- VERSION =
"0.2.1"
- @@detect_between =
{ :cpf => Brid::CPF, :cnpj => Brid::CNPJ, :titulo_eleitor => Brid::TituloEleitor, :pis => Brid::PIS }
Class Method Summary collapse
Class Method Details
.detect(number, between = [:cpf, :cnpj, :titulo_eleitor, :pis]) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/brid/detector.rb', line 9 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 |