hi,
this program gets the rss feed using the feed_tools gem.
then converts into ical. then i ve written it in a file.
hope it will be useful.
require'rubygems'
require'feed_tools'
require'digest/md5'
require 'icalendar'
require 'date'
feed = FeedTools::Feed.open("http://timesofindia.indiatimes.com/rssfeeds/-2128932452.cms")
cal = Icalendar::Calendar.new
cal.custom_property("METHOD","PUBLISH")
feed.items.each do |item|
event = Icalendar::Event.new
event.url=item.link
event.uid=Digest::MD5.hexdigest("#{item.title} #{item.link}")
event.dtstart = item.time.strftime("%Y%m%dT%H%M%S")
event.dtend = item.time.strftime("%Y%m%dT%H%M%S")
event.summary = item.title.to_s
event.description = item.description.to_s
event.klass = "PUBLIC"
cal.add_event(event)
end
ical= cal.to_ical
f=File.open("rss2ical.ics","w")
f.write(ical)
puts ical.to_html
No comments:
Post a Comment