Sha256: 04ed51de9fd6d9dde40a1995c410353c1214979059ffdd0126f5421039587ec9

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 Bytes

Contents

require 'geocoder/results/base'

module Geocoder::Result
  class Mapquest < Base
    def latitude
      @data["latLng"]["lat"]
    end

    def longitude
      @data["latLng"]["lng"]
    end

    def coordinates
      [latitude, longitude]
    end

    def city
      @data['adminArea5']
    end

    def street
      @data['street']
    end

    def state
      @data['adminArea3']
    end

    alias_method :state_code, :state

    #FIXME: these might not be right, unclear with MQ documentation
    alias_method :provinice, :state
    alias_method :province_code, :state

    def postal_code
      @data['postalCode'].to_s
    end

    def country
      @data['adminArea1']
    end

    def country_code
      country
    end

    def address
      [street, city, state, postal_code, country].reject{|s| s.length == 0 }.join(", ")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geocoder-1.1.6 lib/geocoder/results/mapquest.rb
geocoder-1.1.5 lib/geocoder/results/mapquest.rb