Class: ICalAdaptor

Inherits:
Object
  • Object
show all
Defined in:
lib/coursegen/course/lib/ical_adaptor.rb

Instance Method Summary collapse

Constructor Details

#initializeICalAdaptor

Returns a new instance of ICalAdaptor.



6
7
8
9
10
11
# File 'lib/coursegen/course/lib/ical_adaptor.rb', line 6

def initialize
  @cal = Icalendar::Calendar.new
  tzid = "America/New_York"
  tz = TZInfo::Timezone.get tzid
  @cal.add_timezone tz.ical_timezone(Time.now)
end

Instance Method Details

#feed_beginObject



13
# File 'lib/coursegen/course/lib/ical_adaptor.rb', line 13

def feed_begin; end

#feed_endObject



15
# File 'lib/coursegen/course/lib/ical_adaptor.rb', line 15

def feed_end; end

#feed_event(title, dt_start, dt_end, desc, _url) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/coursegen/course/lib/ical_adaptor.rb', line 17

def feed_event(title, dt_start, dt_end, desc, _url)
  event = Icalendar::Event.new
  event.dtstart = dt_start
#    event.dtstart = Icalendar::Values::DateOrDateTime.new(dt_start, tzid: 'UTC').call
  event.dtend = dt_end
#    event.dtend = Icalendar::Values::DateOrDateTime.new(dt_end, tzid: 'UTC').call
  event.summary = title
  event.description = desc
#    event.url = url
  @cal.add_event(event)
end

#feed_renderObject



29
30
31
# File 'lib/coursegen/course/lib/ical_adaptor.rb', line 29

def feed_render
  @cal.to_ical
end