Skip to content

Instantly share code, notes, and snippets.

@obi-a
Created May 22, 2011 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obi-a/985119 to your computer and use it in GitHub Desktop.
Save obi-a/985119 to your computer and use it in GitHub Desktop.
monitor weather alerts in the United States #hackdisrupt
require 'open-uri'
require 'simple-rss'
def weather_alerts(county)
source = "http://alerts.weather.gov/cap/us.php?x=0"
rss = SimpleRSS.parse open(source)
count = 0
alerts = []
rss.items.each do|i|
if i.summary.index(county.upcase) != nil
warning = "WARNING: #{i.summary}" + " Link: #{i.link}"
alerts[count] = warning
count = count + 1
end
end
return alerts
end
puts weather_alerts("white river").inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment