Class: Interage::ParserCNPJ

Inherits:
Object
  • Object
show all
Includes:
NumberHelper
Defined in:
lib/interage/parsers/parser_cnpj.rb

Constant Summary collapse

ALLOWED_SIZE =
14

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NumberHelper

#default_currency_format, #only_numbers

Constructor Details

#initialize(cnpj) ⇒ ParserCNPJ

Returns a new instance of ParserCNPJ.



13
14
15
# File 'lib/interage/parsers/parser_cnpj.rb', line 13

def initialize(cnpj)
  @cnpj = only_numbers(cnpj).to_i
end

Class Method Details

.call(cnpj) ⇒ Object



9
10
11
# File 'lib/interage/parsers/parser_cnpj.rb', line 9

def self.call(cnpj)
  new(cnpj).perform
end

Instance Method Details

#performObject



17
18
19
# File 'lib/interage/parsers/parser_cnpj.rb', line 17

def perform
  "#{prefix_cnpj}/#{sufix_cnpj}".strip if cnpj.positive?
end