Sha256: 93272e5c813a2a2dfb32253681768bd4c1270e4e8c154ad15567f23f4c1e04d8
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require "net/https" require "uri" module GmapsTz class Client include TimeZone FORMAT = "/json" HOST = "maps.googleapis.com" BASE_PATH = "/maps/api" def initialize(options = {}) @key = options[:key] @basic_params = { sensor: false } @basic_params[:key] = options[:key] if options[:key] @basic_params[:client] = options[:client] if options[:client] @basic_params[:signature] = options[:signature] if options[:signature] end def get(path, query_params) uri = generate_uri(path, query_params) response = Net::HTTP.get_response(uri) ResponseParser.new(uri, response).execute end private def generate_uri(path, query_params) URI::HTTPS.build( :host => HOST, :path => BASE_PATH + path + FORMAT, :query => generate_query(@basic_params.merge(query_params)) ) end def generate_query(query_params) query_params.map do |k,v| [CGI.escape(k.to_s), "=", CGI.escape(v.to_s)] end.map(&:join) .join("&") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gmaps_tz-0.0.4 | lib/gmaps_tz/client.rb |