Sha256: d590fbe0de970e8f3e7ab23f9b68281026596763df2a9220f2a4627c722e5e96

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

module MelissaData
  module GeoLookup
    module Geocoder
      extend self

      def address_to_coordinates(address)
        if authenticate
          lat_long = Geokit::Geocoders::GoogleGeocoder.geocode(address)
            .ll
            .split(",")
            .map(&:to_f)
            { latitude: lat_long.first, longitude: lat_long.last }
        end
      end

      def coordinates?(response)
        lat = response[:property_address][:latitude]
        long = response[:property_address][:longitude]
        lat != nil && long != nil
      end

      def authenticate
        Geokit::Geocoders::GoogleGeocoder.api_key = MelissaData.google_maps_api_key
        Geokit::Geocoders::GoogleGeocoder.api_key
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
melissa_data-0.2.9 lib/melissa_data/geo_lookup/geocoder.rb