Class: PisPasep::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pis_pasep/pis_pasep.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/pis_pasep/pis_pasep.rb', line 5

def initialize(number)
  @number = number
  @number = @number =~ PIS_PASEP_REGEX ? format_number! : @number
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



3
4
5
# File 'lib/pis_pasep/pis_pasep.rb', line 3

def number
  @number
end

Instance Method Details

#==(outro) ⇒ Object



20
21
22
# File 'lib/pis_pasep/pis_pasep.rb', line 20

def ==(outro)
  self.number == outro.number
end

#to_sObject



16
17
18
# File 'lib/pis_pasep/pis_pasep.rb', line 16

def to_s
  number
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/pis_pasep/pis_pasep.rb', line 10

def valid?
  return true if @number.nil?
  return false unless format_valid?
  number_valid?
end