class Interage::ParserCep

Constants

ALLOWED_SIZE

Attributes

cep[R]

Public Class Methods

call(cep) click to toggle source
# File lib/interage/parsers/parser_cep.rb, line 9
def self.call(cep)
  new(cep).perform
end
new(cep) click to toggle source
# File lib/interage/parsers/parser_cep.rb, line 13
def initialize(cep)
  @cep = only_numbers(cep).to_i
end

Public Instance Methods

perform() click to toggle source
# File lib/interage/parsers/parser_cep.rb, line 17
def perform
  "#{digits[-8..-4]}-#{digits[-3..]}" if cep.positive?
end

Private Instance Methods

digits() click to toggle source
# File lib/interage/parsers/parser_cep.rb, line 25
def digits
  @digits ||= cep.to_s.rjust(ALLOWED_SIZE, '0')
end