class TaskJuggler::ICalendar

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.

Constants

LINELENGTH

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

Attributes

creationDate[RW]
lastModified[RW]
uid[R]

Public Class Methods

new(uid) click to toggle source
# File lib/taskjuggler/ICalendar.rb, line 178
def initialize(uid)
  @uid = "#{AppConfig.packageName}-#{uid}"
  @creationDate = @lastModified = TjTime.new.utc

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

Public Instance Methods

addEvent(event) click to toggle source

Add a new VEVENT component. For internal use only!

# File lib/taskjuggler/ICalendar.rb, line 193
def addEvent(event)
  @events << event
end
addJournal(journal) click to toggle source

Add a new VJOURNAL component. For internal user only!

# File lib/taskjuggler/ICalendar.rb, line 198
def addJournal(journal)
  @journals << journal
end
addTodo(todo) click to toggle source

Add a new VTODO component. For internal use only!

# File lib/taskjuggler/ICalendar.rb, line 188
def addTodo(todo)
  @todos << todo
end
dateTime(date) click to toggle source
# File lib/taskjuggler/ICalendar.rb, line 220
def dateTime(date)
  date.to_s("%Y%m%dT%H%M%SZ", 'UTC')
end
to_s() click to toggle source
# 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