Class: Cep::CepService
- Inherits:
-
Object
- Object
- Cep::CepService
- Defined in:
- lib/brval/cep/cep_service.rb
Instance Attribute Summary collapse
-
#cep ⇒ Object
Returns the value of attribute cep.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #check ⇒ Object
- #info ⇒ Object
-
#initialize(cep) ⇒ CepService
constructor
A new instance of CepService.
Constructor Details
#initialize(cep) ⇒ CepService
Returns a new instance of CepService.
5 6 7 |
# File 'lib/brval/cep/cep_service.rb', line 5 def initialize cep @cep = cep.to_s.tr('^0-9', '') end |
Instance Attribute Details
#cep ⇒ Object
Returns the value of attribute cep.
3 4 5 |
# File 'lib/brval/cep/cep_service.rb', line 3 def cep @cep end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/brval/cep/cep_service.rb', line 3 def url @url end |
Instance Method Details
#check ⇒ Object
9 10 11 12 13 |
# File 'lib/brval/cep/cep_service.rb', line 9 def check return false if @cep.nil? || @cep.length > 8 json = load_cep_json json_valid?(json) end |
#info ⇒ Object
15 16 17 18 19 |
# File 'lib/brval/cep/cep_service.rb', line 15 def info return response_error if @cep.nil? || @cep.length > 8 json = load_cep_json json_valid?(json) ? translate_params(json) : response_error end |