Sha256: 676c195cc4afcc03007ba23c2b75dae4b5aba02f407f932ed8b36e63b3085d9a
Contents?: true
Size: 617 Bytes
Versions: 2
Compression:
Stored size: 617 Bytes
Contents
require 'service' 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])) end private def fill_from_response(response) @cep = response['cep'] @address = response['logradouro'] @neighborhood = response['bairro'] @city = response['localidade'] @state = response['uf'] @ibge = response['ibge'] @gia = response['gia'] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
viacep-1.0.1 | lib/viacep.rb |
viacep-1.0.0 | lib/viacep.rb |