Class: PasepPisNit::Pis
- Inherits:
-
Object
- Object
- PasepPisNit::Pis
- Defined in:
- lib/pasep-pis-nit/pis.rb
Instance Attribute Summary collapse
- #numero ⇒ Object readonly
Instance Method Summary collapse
- #==(outro_doc) ⇒ Object
-
#initialize(numero) ⇒ Pis
constructor
A new instance of Pis.
- #to_s ⇒ Object
-
#valido? ⇒ Boolean
Verifica se o número possui o formato correto e se constitui um número de documento válido.
Constructor Details
#initialize(numero) ⇒ Pis
Returns a new instance of Pis.
6 7 8 9 10 11 12 |
# File 'lib/pasep-pis-nit/pis.rb', line 6 def initialize(numero) @numero = numero @match = @numero =~ PASEP_PIS_NIT_REGEX @numero_puro = $1 @para_verificacao = $2 @numero = (@match ? format_number! : nil) end |
Instance Attribute Details
#numero ⇒ Object (readonly)
4 5 6 |
# File 'lib/pasep-pis-nit/pis.rb', line 4 def numero @numero end |
Instance Method Details
#==(outro_doc) ⇒ Object
18 19 20 |
# File 'lib/pasep-pis-nit/pis.rb', line 18 def ==(outro_doc) self.numero == outro_doc.numero end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/pasep-pis-nit/pis.rb', line 14 def to_s @numero || '' end |
#valido? ⇒ Boolean
Verifica se o número possui o formato correto e se constitui um número de documento válido
24 25 26 27 |
# File 'lib/pasep-pis-nit/pis.rb', line 24 def valido? return false unless @match verifica_numero end |