Class: PasepPisNit::Pis

Inherits:
Object
  • Object
show all
Defined in:
lib/pasep-pis-nit/pis.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#numeroObject (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_sObject



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

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/pasep-pis-nit/pis.rb', line 24

def valido?
  return false unless @match
  verifica_numero
end