Class: TaskJuggler::ICalendar::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/taskjuggler/ICalendar.rb

Overview

Base class for all ICalendar components.

Direct Known Subclasses

Event, Journal, Todo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ical, uid, summary, startDate) ⇒ Component

Returns a new instance of Component.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/taskjuggler/ICalendar.rb', line 36

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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



33
34
35
# File 'lib/taskjuggler/ICalendar.rb', line 33

def description
  @description
end

#organizerObject

Returns the value of attribute organizer.



33
34
35
# File 'lib/taskjuggler/ICalendar.rb', line 33

def organizer
  @organizer
end

#relatedToObject

Returns the value of attribute relatedTo.



33
34
35
# File 'lib/taskjuggler/ICalendar.rb', line 33

def relatedTo
  @relatedTo
end

#uidObject (readonly)

Returns the value of attribute uid.



34
35
36
# File 'lib/taskjuggler/ICalendar.rb', line 34

def uid
  @uid
end

Instance Method Details

#addAttendee(name, email) ⇒ Object



54
55
56
# File 'lib/taskjuggler/ICalendar.rb', line 54

def addAttendee(name, email)
  @attendees << Person.new(name, email)
end

#setOrganizer(name, email) ⇒ Object



50
51
52
# File 'lib/taskjuggler/ICalendar.rb', line 50

def setOrganizer(name, email)
  @organizer = Person.new(name, email)
end

#to_sObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/taskjuggler/ICalendar.rb', line 58

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