Sha256: 6c1dee67d358f9db92ae5c42b0b5d58d67ccdd5f9abb529b869d09c3a0060f77

Contents?: true

Size: 466 Bytes

Versions: 1

Compression:

Stored size: 466 Bytes

Contents

module GoMaps
  class CEP
    def initialize(cep)
      @response = Nokogiri::XML(open("http://cep.republicavirtual.com.br/web_cep.php?cep=#{cep}"))
      raise GoMaps::AddressNotFoundException if element('resultado') == "0"
    end

    def street
      "#{element('tipo_logradouro')} #{element('logradouro')}"
    end

    def city
      element('cidade')
    end

    private

    def element(name)
      @response.xpath("//#{name}").inner_text
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
go_maps-0.4.1 lib/go_maps/cep.rb