Class: TaskJuggler::ICalendar

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

Overview

This class implements a very basic RFC5545 compliant iCalendar file generator. It currently only supports a very small subset of the tags that are needed for TaskJuggler.

Defined Under Namespace

Classes: Component, Event, Journal, Person, Todo

Constant Summary collapse

LINELENGTH =

The maximum allowed length of a content line without line end character.

75

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uid) ⇒ ICalendar

Returns a new instance of ICalendar.



178
179
180
181
182
183
184
185
# File 'lib/taskjuggler/ICalendar.rb', line 178

def initialize(uid)
  @uid = "#{AppConfig.packageName}-#{uid}"
  @creationDate = @lastModified = TjTime.new.utc

  @todos = []
  @events = []
  @journals = []
end

Instance Attribute Details

#creationDateObject

Returns the value of attribute creationDate.



176
177
178
# File 'lib/taskjuggler/ICalendar.rb', line 176

def creationDate
  @creationDate
end

#lastModifiedObject

Returns the value of attribute lastModified.



176
177
178
# File 'lib/taskjuggler/ICalendar.rb', line 176

def lastModified
  @lastModified
end

#uidObject (readonly)

Returns the value of attribute uid.



175
176
177
# File 'lib/taskjuggler/ICalendar.rb', line 175

def uid
  @uid
end

Instance Method Details

#addEvent(event) ⇒ Object

Add a new VEVENT component. For internal use only!



193
194
195
# File 'lib/taskjuggler/ICalendar.rb', line 193

def addEvent(event)
  @events << event
end

#addJournal(journal) ⇒ Object

Add a new VJOURNAL component. For internal user only!



198
199
200
# File 'lib/taskjuggler/ICalendar.rb', line 198

def addJournal(journal)
  @journals << journal
end

#addTodo(todo) ⇒ Object

Add a new VTODO component. For internal use only!



188
189
190
# File 'lib/taskjuggler/ICalendar.rb', line 188

def addTodo(todo)
  @todos << todo
end

#dateTime(date) ⇒ Object



220
221
222
# File 'lib/taskjuggler/ICalendar.rb', line 220

def dateTime(date)
  date.to_s("%Y%m%dT%H%M%SZ", 'UTC')
end

#to_sObject



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/taskjuggler/ICalendar.rb', line 202

def to_s
  str = <<"EOT"
BEGIN:VCALENDAR
PRODID:-//The #{AppConfig.softwareName} Project/NONSGML #{AppConfig.softwareName} #{AppConfig.version}//EN
VERSION:2.0

EOT
  @todos.each { |todo| str += todo.to_s }
  @events.each { |event| str += event.to_s }
  @journals.each { |journal| str += journal.to_s }

  str << <<"EOT"
END:VCALENDAR
EOT

  foldLines(str)
end