Class: CalInvite::Providers::Ics Private

Inherits:
IcsContent show all
Defined in:
lib/cal_invite/providers/ics.rb,
lib/cal_invite/providers/ics_content.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Compatibility class aliases

Instance Attribute Summary

Attributes inherited from BaseProvider

#event

Instance Method Summary collapse

Methods inherited from BaseProvider

#initialize

Constructor Details

This class inherits a constructor from BaseProvider

Instance Method Details

#generateString

Generates the complete ICS calendar content with proper calendar properties. Handles all event types: all-day, regular, and multi-day sessions.

Returns:

  • (String)

    The complete ICS calendar content in iCalendar format



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cal_invite/providers/ics.rb', line 43

def generate
  calendar_lines = [
    "BEGIN:VCALENDAR",
    "VERSION:2.0",
    "PRODID:-//CalInvite//EN",
    "CALSCALE:GREGORIAN",
    "METHOD:PUBLISH"
  ]

  if event.all_day
    calendar_lines.concat(generate_all_day_event)
  elsif event.multi_day_sessions.any?
    event.multi_day_sessions.each do |session|
      calendar_lines.concat(generate_vevent(session[:start_time], session[:end_time]))
    end
  else
    calendar_lines.concat(generate_vevent(event.start_time, event.end_time))
  end

  calendar_lines << "END:VCALENDAR"
  calendar_lines.join("\r\n")
end