Sha256: bb629e1645ec8edc0a1676d39c95d1fca01a10a6537d68aadce21a93b7e4a447

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

require "us_time_zones/version"

require "json"
require "httparty"

class USTZones
	def self.getZone(lat, lng)
		url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=#{lat},#{lng}&key=AIzaSyBgUT0t3K3y9cKJgITa8X1O7uGYjguNZT4"
		response = HTTParty.get(url).to_json
		response = JSON.parse(response)

		if response["results"] == []
			p "Error"
		elsif response["results"][0]["formatted_address"].include?("USA")
			p "You're in the USA"
		else
			p "You're not in the USA"
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
us_time_zones-1.0.4 lib/us_time_zones.rb