Module: MelissaData::GeoLookup::Geocoder
Instance Method Summary collapse
Instance Method Details
#address_to_coordinates(address) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/melissa_data/geo_lookup/geocoder.rb', line 6 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 |
#authenticate ⇒ Object
26 27 28 29 |
# File 'lib/melissa_data/geo_lookup/geocoder.rb', line 26 def authenticate Geokit::Geocoders::GoogleGeocoder.api_key = MelissaData.google_maps_api_key Geokit::Geocoders::GoogleGeocoder.api_key end |
#coordinates?(response) ⇒ Boolean
16 17 18 19 20 21 22 23 24 |
# File 'lib/melissa_data/geo_lookup/geocoder.rb', line 16 def coordinates?(response) if !response[:errors] && !response[:property_address]&.empty? lat = response.fetch(:property_address)[:latitude] long =response.fetch(:property_address)[:longitude] lat != nil && long != nil else false end end |