Created
March 16, 2011 07:24
-
-
Save basyura/872142 to your computer and use it in GitHub Desktop.
earthquake-growler.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby | |
#-*- coding: utf-8 -*- | |
require 'ruby-growl' | |
require 'rss' | |
g = Growl.new 'localhost', 'ruby-growl', ['ruby-growl Notification'] | |
g.notify 'ruby-growl Notification', 'earthquake', 'start' | |
uri = 'http://tenki.jp/component/static_api/rss/earthquake/recent_entries_by_day.xml' | |
update_time = Time.now | |
while true | |
RSS::Parser.parse(uri).items.reverse.each do |item| | |
next if item.date <= update_time | |
status = item.title + " - " + item.description | |
g.notify "ruby-growl Notification", "earthquake", status | |
update_time = item.date | |
end | |
puts "sleep ... last update is #{update_time.strftime("%H:%M:%S")}" | |
sleep 30 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment