Class: Timetrap::Formatters::Ical

Inherits:
Object
  • Object
show all
Includes:
Icalendar
Defined in:
lib/timetrap/formatters/ical.rb

Instance Method Summary collapse

Constructor Details

#initialize(entries) ⇒ Ical

Returns a new instance of Ical.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/timetrap/formatters/ical.rb', line 24

def initialize entries
  entries.each do |entry|
    next unless entry.end
    calendar.event do |e|
      e.dtstart = DateTime.parse(entry.start.to_s)
      e.dtend = DateTime.parse(entry.end.to_s)
      e.summary = entry.note
      e.description = entry.note
    end
  end
  calendar.publish
end

Instance Method Details

#calendarObject



16
17
18
# File 'lib/timetrap/formatters/ical.rb', line 16

def calendar
  @calendar ||= Calendar.new
end

#outputObject



20
21
22
# File 'lib/timetrap/formatters/ical.rb', line 20

def output
  calendar.to_ical
end