<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Andrew E. Bruno &#187; Ruby</title>
	<atom:link href="http://left.subtree.org/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://left.subtree.org</link>
	<description>A sourceful of secrets</description>
	<lastBuildDate>Mon, 10 May 2010 03:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='left.subtree.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/e14c799c6e8030a8abefcb495c0b0e17?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Andrew E. Bruno &#187; Ruby</title>
		<link>http://left.subtree.org</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://left.subtree.org/osd.xml" title="Andrew E. Bruno" />
	<atom:link rel='hub' href='http://left.subtree.org/?pushpress=hub'/>
		<item>
		<title>Creating iCalendar Files in Ruby</title>
		<link>http://left.subtree.org/2007/02/06/creating-icalendar-files-in-ruby/</link>
		<comments>http://left.subtree.org/2007/02/06/creating-icalendar-files-in-ruby/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 06:24:50 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2007/02/06/creating-icalendar-files-in-ruby/</guid>
		<description><![CDATA[I recently came across a great ruby module called icalendar for working with iCalendar files. For a quick example here&#8217;s some code that generates the Buffalo Sabres 06/07 schedule in iCalendar format. The source data comes from the Excel spreadsheet available here which gets converted to CSV before running through the script. require 'rubygems' require [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=8&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently came across a great ruby module called <a href="http://icalendar.rubyforge.org/">icalendar</a> for working with <a href="http://en.wikipedia.org/wiki/ICalendar">iCalendar</a> files. For a quick example here&#8217;s some code that generates the <a href="http://www.sabres.com">Buffalo Sabres</a> 06/07 schedule in iCalendar format. The source data comes from the Excel spreadsheet available <a href="http://www.sabres.com/downloads_html.cfm">here</a> which gets converted to CSV before running through the script.</p>
<pre class="brush: ruby;">
require 'rubygems'
require 'icalendar'
require 'csv'

if ARGV.size != 1
    puts &quot;usage: ruby sabres_ical [schedule.csv]&quot;
    exit;
end

cal = Icalendar::Calendar.new

CSV.open(ARGV[0], 'r') do |row|
    event = cal.event
    event.timestamp = DateTime.now
    event.summary = row[0]
    event.description = row[0]
    event.location = row[16] 

    start_date = Date.parse(row[1])
    end_date = Date.parse(row[3])
    game_time = row[2]

    event.start = DateTime.parse(start_date.to_s + &quot; &quot; + game_time)

    # Games usually last about 3 hours
    (h,m,s) = game_time.split(&quot;:&quot;)
    endTime = [h.to_i + 3,m,s].join(&quot;:&quot;)
    event.end = DateTime.parse(end_date.to_s + &quot; &quot; + endTime)
end

puts cal.to_ical
</pre>
<p>Here&#8217;s an example of the output which is sent to stdout:</p>
<pre class="brush: plain;">
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:iCalendar-Ruby
BEGIN:VEVENT
DTEND:20061006T223000
UID:2007-01-16T17:59:38-0800_408345411@sugaree
DESCRIPTION:Sabres vs. Montreal
SUMMARY:Sabres vs. Montreal
DTSTART:20061006T193000
DTSTAMP:20070116T175938
SEQ:0
LOCATION:HOME
END:VEVENT
BEGIN:VEVENT
DTEND:20061014T220000
UID:2007-01-16T17:59:38-0800_606587692@sugaree
DESCRIPTION:Sabres vs. NY Rangers
SUMMARY:Sabres vs. NY Rangers
DTSTART:20061014T190000
DTSTAMP:20070116T175938
SEQ:0
LOCATION:HOME
END:VEVENT
</pre>
<p>If you&#8217;re a Sabres fan and not able to run ruby scripts you can download the iCal version of the <a href="http://www.qnot.org/code/Sabres-06-07.ics">Sabres 06/07 schedule here</a> for importing into your favorite <a href="http://www.mozilla.org/projects/calendar/sunbird/">calendaring</a> program. For some reason there are some games missing in the source Excel spreadsheet so unfortunately they will also be missing in the iCalendar version. I don&#8217;t make any guarantees to it&#8217;s correctness so if you find an error or miss a game you&#8217;ve been warned.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=8&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2007/02/06/creating-icalendar-files-in-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>
	</item>
	</channel>
</rss>