Class: Rem2ics::Event
- Inherits:
-
Object
- Object
- Rem2ics::Event
- Defined in:
- lib/rem2ics/event.rb
Overview
One reminder, as an iCalendar event.
The iCalendar is built with the icalendar gem rather than by printing lines: escaping, folding at 75 octets, CRLF endings and DTSTAMP are all spelled out in RFC 5545, all fiddly, and all already written.
What is decided here is the mapping, and it is a small list:
the reminder's message SUMMARY, from Remind's CAL_MODE rendering,
which is where a %"…%" title is honoured
the rest of the message DESCRIPTION, from the NORMAL_MODE rendering
the trigger DTSTART, and RRULE or RDATE (see Recurrence)
AT the time on DTSTART
DURATION DTEND
+n advance warning VALARM, n days or n minutes before
Constant Summary collapse
- ALL_DAY =
A reminder with no AT clause is an all-day event, and an all-day event's DTEND is the day after: the RFC's end is exclusive.
1- MINUTES_PER_HOUR =
60- UID_SUFFIX =
UIDs have to survive re-importing the same file, or every conversion creates duplicates instead of updating what is there. A digest of the reminder as written plus the date it starts on is stable across runs and different between reminders.
"rem2ics"
Instance Attribute Summary collapse
-
#organizer ⇒ Object
readonly
Returns the value of attribute organizer.
-
#recurrence ⇒ Object
readonly
Returns the value of attribute recurrence.
-
#reminder ⇒ Object
readonly
Returns the value of attribute reminder.
Instance Method Summary collapse
-
#initialize(reminder, recurrence:, organizer:) ⇒ Event
constructor
A new instance of Event.
- #to_ical_event ⇒ Object
Constructor Details
#initialize(reminder, recurrence:, organizer:) ⇒ Event
Returns a new instance of Event.
39 40 41 42 43 |
# File 'lib/rem2ics/event.rb', line 39 def initialize(reminder, recurrence:, organizer:) @reminder = reminder @recurrence = recurrence @organizer = organizer end |
Instance Attribute Details
#organizer ⇒ Object (readonly)
Returns the value of attribute organizer.
37 38 39 |
# File 'lib/rem2ics/event.rb', line 37 def organizer @organizer end |
#recurrence ⇒ Object (readonly)
Returns the value of attribute recurrence.
37 38 39 |
# File 'lib/rem2ics/event.rb', line 37 def recurrence @recurrence end |
#reminder ⇒ Object (readonly)
Returns the value of attribute reminder.
37 38 39 |
# File 'lib/rem2ics/event.rb', line 37 def reminder @reminder end |
Instance Method Details
#to_ical_event ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rem2ics/event.rb', line 45 def to_ical_event Icalendar::Event.new.tap do |event| event.uid = uid event.summary = reminder.summary event.description = reminder.description event.organizer = Icalendar::Values::CalAddress.new("mailto:#{organizer}") event.ip_class = "PUBLIC" add_dates(event) add_recurrence(event) add_alarms(event) end end |