Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created May 6, 2013 20:53
Show Gist options
  • Save ashaw/5528106 to your computer and use it in GitHub Desktop.
Save ashaw/5528106 to your computer and use it in GitHub Desktop.
require 'uri'
require 'net/http'
require 'base64'
require 'openssl'
require 'json'
class GoogGeocoder
PATH = "/maps/api/geocode/json?sensor=false"
def initialize(address)
@address = address
@path = "#{PATH}&address=#{URI.encode @address}"
geocode!
end
def resp
JSON.parse @resp
end
private
def geocode!
@resp = Net::HTTP.get("maps.googleapis.com", "#{@path}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment