Module: ActAsCnpjCpf::Base
Instance Attribute Summary collapse
-
#numero ⇒ Object
readonly
Returns the value of attribute numero.
Instance Method Summary collapse
Instance Attribute Details
#numero ⇒ Object (readonly)
Returns the value of attribute numero.
3 4 5 |
# File 'lib/act_as_cnpj_cpf/base.rb', line 3 def numero @numero end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 |
# File 'lib/act_as_cnpj_cpf/base.rb', line 22 def == other other.respond_to?(:numero) ? self.numero == other.numero : self.numero == other end |
#initialize(numero) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/act_as_cnpj_cpf/base.rb', line 5 def initialize(numero) @numero = numero.to_s.gsub(/[^0-9]/, '') @match = @numero =~ self.class::REGEX @puro = $1 @digito = $2 @numero = valido? ? $1+$2 : numero end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/act_as_cnpj_cpf/base.rb', line 13 def to_s @numero end |
#valido? ⇒ Boolean
17 18 19 20 |
# File 'lib/act_as_cnpj_cpf/base.rb', line 17 def valido? return false unless @match verifica_numero end |