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.



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

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.



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

def creationDate
  @creationDate
end

#lastModifiedObject

Returns the value of attribute lastModified.



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

def lastModified
  @lastModified
end

#uidObject (readonly)

Returns the value of attribute uid.



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

def uid
  @uid
end

Instance Method Details

#addEvent(event) ⇒ Object

Add a new VEVENT component. For internal use only!



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

def addEvent(event)
  @events << event
end

#addJournal(journal) ⇒ Object

Add a new VJOURNAL component. For internal user only!



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

def addJournal(journal)
  @journals << journal
end

#addTodo(todo) ⇒ Object

Add a new VTODO component. For internal use only!



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

def addTodo(todo)
  @todos << todo
end

#dateTime(date) ⇒ Object



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

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

#to_sObject



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

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