Class: Brid::CNPJ
Instance Attribute Summary
Attributes inherited from GenericID
#number
Instance Method Summary
collapse
Methods inherited from GenericID
#check_digits, #freeze, #initialize, #invalid_sequential?, #sequential, #valid?
Constructor Details
This class inherits a constructor from GenericID
Instance Method Details
#check_digits_length ⇒ Object
4
|
# File 'lib/brid/ids/cnpj.rb', line 4
def check_digits_length; 2; end
|
#inspect ⇒ Object
11
12
13
|
# File 'lib/brid/ids/cnpj.rb', line 11
def inspect
"#<CNPJ: #{to_s} #{valid? ? 'valid': 'not valid'} >"
end
|
#number_length ⇒ Object
3
|
# File 'lib/brid/ids/cnpj.rb', line 3
def number_length; 14; end
|
#to_s ⇒ Object
6
7
8
9
|
# File 'lib/brid/ids/cnpj.rb', line 6
def to_s
er = /^(.{2})(.{3})(.{3})(.{4})(.{2})/
"#{@number.gsub(er, '\1.\2.\3/\4-\5')}"
end
|