Class: CalInvite::Providers::Ics
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- CalInvite::Providers::Ics
- Defined in:
- lib/cal_invite/providers/ics.rb
Overview
Generic ICS provider for generating standard iCalendar (.ics) files. This provider generates ICS files that are compatible with most calendar applications. Supports all-day events, regular events, and multi-day sessions with proper timezone handling.
Instance Attribute Summary
Attributes inherited from BaseProvider
Instance Method Summary collapse
-
#generate ⇒ String
Generates the complete ICS calendar content with proper calendar properties.
Methods inherited from BaseProvider
Constructor Details
This class inherits a constructor from BaseProvider
Instance Method Details
#generate ⇒ String
Generates the complete ICS calendar content with proper calendar properties. Handles all event types: all-day, regular, and multi-day sessions.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cal_invite/providers/ics.rb', line 43 def generate calendar_lines = [ "BEGIN:VCALENDAR", "VERSION:2.0", "PRODID:-//CalInvite//EN", "CALSCALE:GREGORIAN", "METHOD:#{method_value}" ] calendar_lines << "X-WR-CALNAME:#{escape_text(event.calendar_name)}" if event.calendar_name unless event.all_day calendar_lines.concat(vtimezone_lines || []) end 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 |