Sha256: 575172a71905ce588d14b710b3fc4142fc0ac9793a6dfe4dc3fa1afbdc456b9a

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

require 'quick_travel/adapter'
require 'geokit'

module QuickTravel
  class Address < Adapter
    def country_name
      QuickTravel::Country.find(@country_id).name
    end

    def geocode
      @_geocode ||= QuickTravel::Cache.cache("geocode_#{self}") {
        Geokit::Geocoders::MultiGeocoder.geocode(to_s)
      }
    rescue Geokit::Geocoders::TooManyQueriesError
      nil # do not cache, do not error
    end

    def to_s
      "#{address_line1} #{address_line2}, #{city}, #{post_code}, #{state}, #{country_name}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quicktravel_client-2.0.0 lib/quick_travel/address.rb