Skip to content

Instantly share code, notes, and snippets.

@jpf
Created February 17, 2010 08:18
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 jpf/306426 to your computer and use it in GitHub Desktop.
Save jpf/306426 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'xmlsimple'
require 'open-uri'
require 'sinatra'
url = 'http://www.dnalounge.com/calendar/dnalounge.rss'
c = ''
c = c + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
c = c + "<Response>\n"
doc = XmlSimple.xml_in(open(url).read)
doc['channel'][0]['item'].each do |item|
date = Date.parse(item['date'][0])
age = item['age'][0] + ' and up' unless item['age'][0] == 'all ages'
[date.strftime('%A, %B %e'),item['title'][1].sub('&','and'),item['time'][0].sub('-','until'),age].each do |line|
c = c + " <Say>%s</Say>\n" % line
end
end
c = c + "</Response>\n"
post '/' do
response.headers['Content-Type'] = 'text/xml'
c #alendar
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment