Class: Google::InternalGoogleApi

Inherits:
Object
  • Object
show all
Defined in:
lib/Time_Traveler/google_api_inter.rb

Overview

Service for all Google API calls

Constant Summary collapse

Google_URL =

Setting the URL and parameters

'https://maps.googleapis.com/maps/api/'
Search_Type =
'place/textsearch'
Return_Type =
'json'
Google_API_URL =
URI.join(Google_URL, "#{Search_Type}/", "#{Return_Type}")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#google_dataObject (readonly)

Search_URL = URI.join(Google_API_URL, “#Parms”) maps.googleapis.com/maps/api/place/textsearch/xml?query=清華大學&key=AIzaSyADFcZbph8b9jvV5D9zgrlOm2oMQpv6krI



13
14
15
# File 'lib/Time_Traveler/google_api_inter.rb', line 13

def google_data
  @google_data
end

Class Method Details

.configObject



19
20
21
22
# File 'lib/Time_Traveler/google_api_inter.rb', line 19

def self.config
  return @config if @config
  @config = { googlemap_id: ENV['GOOGLE_API'] }
end

.config=(credentials) ⇒ Object



15
16
17
# File 'lib/Time_Traveler/google_api_inter.rb', line 15

def self.config=(credentials)
  @config ? @config.update(credentials) : @config = credentials
end

.this_rating(station) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Time_Traveler/google_api_inter.rb', line 24

def self.this_rating(station)
  return @this_rating if @this_rating

  station_rating = HTTP.get(Google_API_URL,
    params:
    {
      key: 'AIzaSyADFcZbph8b9jvV5D9zgrlOm2oMQpv6krI',
      query: station
    })
    print station_rating
  this_station_rating = JSON.load(station_rating.to_s)['results']
end