Skip to content

Instantly share code, notes, and snippets.

@clifton
Created June 13, 2011 22:10
Show Gist options
  • Save clifton/1023851 to your computer and use it in GitHub Desktop.
Save clifton/1023851 to your computer and use it in GitHub Desktop.
res = Faraday.get("http://weather.yahooapis.com/forecastrss?w=#{woe_id}")
xml = Nokogiri::XML(res.body)
loc_xml = xml.css('yweather|location')
weather_xml = xml.css('yweather|condition')
@weather_data = {
:city => loc_xml.attr('city').text,
:state => loc_xml.attr('region').text,
:country => loc_xml.attr('country').text,
:temp => weather_xml.attr('temp').text,
:text => weather_xml.attr('text').text,
:code => code = weather_xml.attr('code').text,
:style => WEATHER_CODES[code].rubify,
:stamp => Time.now.to_i
}
$redis.hset('weather-by-zip', zip, @weather_data.to_json) \
if code != '3200'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment