Ruby東海第5回ハンズオンの作品

#!/usr/bin/ruby

require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'

require 'twitter'

# url or local file
source = "http://groups.google.co.jp/group/ruby-tokai/feed/rss_v2_0_msgs.xml"
content = "" # raw content of rss feed will be loaded here
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)

twit = Twitter::Base.new("babydaemons@gmail.com", "rubytokai123")
print "RSS title: ", rss.channel.title, "\n"
print "RSS link: ", rss.channel.link, "\n"

print "title of first item: ", rss.items[0].title, "\n"
print "link of first item: ", rss.items[0].link, "\n"
print "description of first item: ", rss.items[0].description, "\n"
print "date of first item: ", rss.items[0].date, "\n"

message = rss.items[0].title + ' ' + rss.item[0].link
p message
twit.post message