Sha256: 20de7668a81b6dd8a33155e6beefef68382b823d657bdab78582133bc4f054dd

Contents?: true

Size: 890 Bytes

Versions: 4

Compression:

Stored size: 890 Bytes

Contents

require 'geocoder/lookups/base'
require "geocoder/results/yahoo"

module Geocoder::Lookup
  class Yahoo < Base

    private # ---------------------------------------------------------------

    def results(query, reverse = false)
      return [] unless doc = fetch_data(query, reverse)
      if doc = doc['ResultSet'] and doc['Error'] == 0
        return doc['Found'] > 0 ? doc['Results'] : []
      else
        warn "Yahoo Geocoding API error: #{doc['Error']} (#{doc['ErrorMessage']})."
        return []
      end
    end

    def query_url(query, reverse = false)
      params = {
        :location =>  query,
        :flags => "JXTSR",
        :gflags => "AC#{'R' if reverse}",
        :locale => "#{Geocoder::Configuration.language}_US",
        :appid => Geocoder::Configuration.api_key
      }
      "http://where.yahooapis.com/geocode?" + hash_to_query(params)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
geocoder-0.9.13 lib/geocoder/lookups/yahoo.rb
geocoder-0.9.12 lib/geocoder/lookups/yahoo.rb
rails-geocoder-0.9.11 lib/geocoder/lookups/yahoo.rb
geocoder-0.9.11 lib/geocoder/lookups/yahoo.rb