Class: Decidim::Calendar::EventToIcal

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper, TranslationsHelper
Defined in:
app/services/decidim/calendar/event_to_ical.rb

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ EventToIcal

Returns a new instance of EventToIcal.



9
10
11
# File 'app/services/decidim/calendar/event_to_ical.rb', line 9

def initialize(event)
  @event = event
end

Instance Method Details

#icalObject



13
14
15
16
17
18
19
20
21
22
# File 'app/services/decidim/calendar/event_to_ical.rb', line 13

def ical
  return @ical if @ical

  @ical = Icalendar::Event.new
  @ical.dtstart = Icalendar::Values::DateTime.new(@event.start)
  @ical.dtend = Icalendar::Values::DateTime.new(@event.finish)
  @ical.summary = translated_attribute @event.full_title
  @ical.url = @event.link
  @ical
end