Class: ActAsCnpjCpf::Cpf
- Inherits:
-
Object
- Object
- ActAsCnpjCpf::Cpf
- Includes:
- Base
- Defined in:
- lib/act_as_cnpj_cpf/cpf.rb
Constant Summary collapse
- LENGTH =
11- REGEX =
/^(\d{3}\.?\d{3}\.?\d{3})-?(\d{2})$/- ALGS_1 =
[10, 9, 8, 7, 6, 5, 4, 3, 2]
- ALGS_2 =
[11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
Methods included from Base
#==, #initialize, #to_s, #valido?
Instance Method Details
#formatado ⇒ Object
10 11 12 13 |
# File 'lib/act_as_cnpj_cpf/cpf.rb', line 10 def formatado @numero =~ /(\d{3})\.?(\d{3})\.?(\d{3})-?(\d{2})/ valido? ? "#{$1}.#{$2}.#{$3}-#{$4}" : '' end |