Class: GoogleLocationsClient
- Defined in:
- lib/whos_using_what/api_clients/google_locations_client.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #api_get_google_location_data(zip_code) ⇒ Object
- #get_coords_from_google_location_resp_helper(resp_map) ⇒ Object
-
#initialize ⇒ GoogleLocationsClient
constructor
A new instance of GoogleLocationsClient.
Methods inherited from Base
Constructor Details
#initialize ⇒ GoogleLocationsClient
Returns a new instance of GoogleLocationsClient.
7 8 9 10 11 12 |
# File 'lib/whos_using_what/api_clients/google_locations_client.rb', line 7 def initialize #todo pull this from config file if this becomes needed @google_api_key = "" end |
Instance Method Details
#api_get_google_location_data(zip_code) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/whos_using_what/api_clients/google_locations_client.rb', line 15 def api_get_google_location_data zip_code params = "q=" << zip_code "&output=json" "&key=" << @google_api_key @geo_code_api_url_base = "http://maps.google.com/maps/geo?" begin rawHtml = RestClient.get(@geo_code_api_url_base << params) rescue Exception => e puts e end json_resp = JSON.parse(rawHtml.body) resp_map = nil begin resp_map = json_resp["Placemark"][0] rescue end if !resp_map return nil end resp_map end |
#get_coords_from_google_location_resp_helper(resp_map) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/whos_using_what/api_clients/google_locations_client.rb', line 46 def get_coords_from_google_location_resp_helper resp_map keys_arr1 = ["Point", "coordinates", 0] keys_arr2 = ["Point", "coordinates", 1] part1 = MapDataExtractionUtil.safe_extract_helper keys_arr1, resp_map, nil, nil part2 = MapDataExtractionUtil.safe_extract_helper keys_arr2, resp_map, nil, nil arr = [part1, part2] end |