class TaskJuggler::ICalendar::Component

Base class for all ICalendar components.

Attributes

description[RW]
organizer[RW]
relatedTo[RW]
uid[R]

Public Class Methods

new(ical, uid, summary, startDate) click to toggle source
# File lib/taskjuggler/ICalendar.rb, line 35
def initialize(ical, uid, summary, startDate)
  @ical = ical
  @type = self.class.to_s.split('::').last.upcase
  @uid = uid + "-#{@type}"
  @summary = summary
  @startDate = startDate

  # Optional attributes
  @description = nil
  @relatedTo = nil
  @organizer = nil
  @attendees = []
end

Public Instance Methods

addAttendee(name, email) click to toggle source
# File lib/taskjuggler/ICalendar.rb, line 53
def addAttendee(name, email)
  @attendees << Person.new(name, email)
end
setOrganizer(name, email) click to toggle source
# File lib/taskjuggler/ICalendar.rb, line 49
def setOrganizer(name, email)
  @organizer = Person.new(name, email)
end
to_s() { || ... } click to toggle source
# File lib/taskjuggler/ICalendar.rb, line 57
      def to_s
        str = <<"EOT"
BEGIN:V#{@type}
DTSTAMP:#{dateTime(TjTime.new.utc)}
CREATED:#{dateTime(@ical.creationDate)}
UID:#{@uid}
LAST-MODIFIED:#{dateTime(@ical.lastModified)}
SUMMARY:#{quoted(@summary)}
DTSTART:#{dateTime(@startDate)}
EOT
        str += "DESCRIPTION:#{quoted(@description)}\n" if @description
        str += "RELATED-TO:#{@relatedTo}\n" if @relatedTo

        if @organizer
          str += "ORGANIZER;CN=#{@organizer.name}:mailto:#{@organizer.email}\n"
        end
        @attendees.each do |attendee|
          str += "ATTENDEE;CN=#{attendee.name}:mailto:#{attendee.email}\n"
        end

        str += yield if block_given?

        str += "END:V#{@type}\n\n"
      end