Skip to content

Instantly share code, notes, and snippets.

@semmons99
Created February 10, 2011 18:13
Show Gist options
  • Save semmons99/821010 to your computer and use it in GitHub Desktop.
Save semmons99/821010 to your computer and use it in GitHub Desktop.
def response_geo_weather
geo_weather = Hash.new {|h, k| h[k] = {}}
geo_weather['ip'] = geo_location.ip
geo_weather['current_date_time'] = weather.current_date_time
geo_weather['location']['latitude'] = geo_location.latitude
geo_weather['location']['longitude'] = geo_location.longitude
geo_weather['location']['city'] = geo_location.city
geo_weather['location']['country'] = geo_location.country
geo_weather['location']['country_code'] = geo_location.country_code
geo_weather['location']['gmt_offset'] = geo_location.gmt_offset
geo_weather['weather']['condition'] = weather.condition
geo_weather['weather']['temp_f'] = weather.temp_f
geo_weather['weather']['temp_c'] = weather.temp_c
geo_weather['weather']['humidity'] = weather.humidity
geo_weather['weather']['wind_condition'] = weather.wind_condition
geo_weather.to_json
rescue
{:status => "There is something wrong in preventing us from getting information of your location. You could try to pass another ip instead."}.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment