Class: TaskJuggler::ICalendar::Component
- Defined in:
- lib/taskjuggler/ICalendar.rb
Overview
Base class for all ICalendar components.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#organizer ⇒ Object
Returns the value of attribute organizer.
-
#relatedTo ⇒ Object
Returns the value of attribute relatedTo.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
- #addAttendee(name, email) ⇒ Object
-
#initialize(ical, uid, summary, startDate) ⇒ Component
constructor
A new instance of Component.
- #setOrganizer(name, email) ⇒ Object
- #to_s ⇒ Object
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
#description ⇒ Object
Returns the value of attribute description.
33 34 35 |
# File 'lib/taskjuggler/ICalendar.rb', line 33 def description @description end |
#organizer ⇒ Object
Returns the value of attribute organizer.
33 34 35 |
# File 'lib/taskjuggler/ICalendar.rb', line 33 def organizer @organizer end |
#relatedTo ⇒ Object
Returns the value of attribute relatedTo.
33 34 35 |
# File 'lib/taskjuggler/ICalendar.rb', line 33 def @relatedTo end |
#uid ⇒ Object (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_s ⇒ Object
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 |