Sha256: 726fe922085118ea5fc7f086c79c0c26f6100f992bab4824fbc5e10b01bc1f0c

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

require 'geocoder'

module Geong
  module Geocoder
    class GeocoderHandler
      def coordinates(address)
        result = ::Geocoder.coordinates(address)
        if result.nil?
          raise NoResultException, "coordinates not found. address: #{address}"
        end
        location = Location.new
        location.latitude = result[0]
        location.longitude = result[1]
        location
      rescue TimeoutError => e
        raise TimeoutException, e.message
      end
      
      def address(query)
        result = ::Geocoder.address(query)
        if result.nil?
          raise NoResultException, "address not found. query: #{query}"
        end
        result
      rescue TimeoutError => e
        raise TimeoutException, e.message
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geong-0.0.2 lib/geong/geocoder/geocoder_handler.rb
geong-0.0.1 lib/geong/geocoder/geocoder_handler.rb