zeus.ugent.be/lib/helpers/ical.rb

20 lines
346 B
Ruby
Raw Normal View History

2016-07-26 22:13:36 +00:00
module IcalHelper
def event_calendar
cal = Icalendar::Calendar.new
2016-08-23 18:21:02 +00:00
items.find_all('/events/*/*.md').each do |i|
cal.add_event(event_for(i))
end
2016-07-26 22:13:36 +00:00
cal.to_ical
end
2016-08-23 18:21:02 +00:00
def event_for(item)
2016-07-26 22:13:36 +00:00
event = Icalendar::Event.new
2016-08-23 18:21:02 +00:00
event.dtstart = Date.parse(item[:time])
2016-07-26 22:13:36 +00:00
event.summary = 'A great event!'
event
end
end