Class: Denso::Calendar::Formatter::Ical

Inherits:
Object
  • Object
show all
Defined in:
lib/denso/calendar/formatter/ical.rb

Instance Method Summary collapse

Instance Method Details

#format(calendar) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/denso/calendar/formatter/ical.rb', line 7

def format(calendar)
  require 'icalendar'

  cal = Icalendar::Calendar.new
  calendar.holidays.each do |holiday|
    cal.event do |e|
      e.dtstart = Icalendar::Values::Date.new(holiday)
      e.dtend = Icalendar::Values::Date.new(holiday)
    end
  end
  cal.publish

  cal.to_ical
end