lib/viacep.rb in viacep-1.0.1 vs lib/viacep.rb in viacep-2.0.0
- old
+ new
@@ -3,16 +3,18 @@
module ViaCep
class Address
attr_reader :cep, :address, :neighborhood, :city, :state, :ibge, :gia
def initialize(cep, options = {})
- cep = cep.delete('^0-9')
- fill_from_response(Service.fetch(cep, options[:timeout]))
+ cep = cep.to_s.delete('^0-9')
+
+ response = Service.fetch cep, options[:timeout]
+ fill_from response
end
private
- def fill_from_response(response)
+ def fill_from(response)
@cep = response['cep']
@address = response['logradouro']
@neighborhood = response['bairro']
@city = response['localidade']
@state = response['uf']