Class Vpim::Icalendar
In: lib/vpim/address.rb
Parent: Object

An iCalendar.

A Calendar is some meta-information followed by a sequence of components.

Defined components are Event, Todo, Freebusy, Journal, and Timezone, each of which are represented by their own class, though they share many properties in common. For example, Event and Todo may both contain multiple Alarm components.


The iCalendar format is specified by a series of IETF documents:

  • rfc2445.txt: Internet Calendaring and Scheduling Core Object Specification
  • rfc2446.txt: iCalendar Transport-Independent Interoperability Protocol (iTIP) Scheduling Events, BusyTime, To-dos and Journal Entries
  • rfc2447.txt: iCalendar Message-Based Interoperability Protocol

iCalendar and vCalendar

iCalendar files have VERSION:2.0 and vCalendar have VERSION:1.0. iCalendar (RFC 2445) is based on vCalendar, but but is not very compatible. While much appears to be similar, the recurrence rule syntax is completely different.

iCalendars are usually transmitted in files with .ics extensions.


<<   add_event   calscale   components   create   create2   create_reply   decode   each   encode   events   journals   producer   protocol   protocol?   push   to_s   todos   version  

Included Modules

Vpim Enumerable

Classes and Modules

Class Vpim::Icalendar::Address
Class Vpim::Icalendar::Vevent
Class Vpim::Icalendar::Vjournal
Class Vpim::Icalendar::Vtodo

Public Class methods

Create a new Icalendar object with the minimal set of fields for a valid Calendar. If specified, fields must be an array of DirectoryInfo::Field objects to add. They can override the the default Calendar fields, so, for example, this can be used to set a custom PRODID field.

The producer ID defaults to Vpim::PRODID but you can set it to something specific to your application.

Create a new Icalendar object with a protocol method of REPLY.

Meeting requests, and such, are Calendar containers with a protocol method of REQUEST, and contains some number of Events, Todos, etc., that may need replying to. In order to reply to any of these components of a request, you must first build a Calendar object to hold your reply components.

This method builds the reply Calendar, you then will add to it replies to the specific components of the request Calendar that you are replying to. If you have any particular fields that you want to be in the Calendar, other than the defaults, then can be supplied as fields, an array of Field objects.

Decode iCalendar data into an array of Icalendar objects.

Since iCalendars are self-delimited (by a BEGIN:VCALENDAR and an END:VCALENDAR), multiple iCalendars can be concatenated into a single file.

cal must be String or IO, or implement each by returning each line in the input as those classes do.

Public Instance methods


Alias for push

Add an event to this calendar.

Yields an event maker, Icalendar::Vevent::Maker.

The value of the CALSCALE: property, or "GREGORIAN" if CALSCALE: is not present.

This is of academic interest only. There aren‘t any other calendar scales defined, and given that its hard enough just dealing with Gregorian calendars, there probably won‘t be.

The array of all supported calendar components. If a class is provided, return only the components of that class.

If a block is provided, yield the components instead of returning them.


  => array of all calendar components

  calendar.components(Vpim::Icalendar::Vtodo) {|c| c... }
  => yield all todo components

  calendar.components {|c| c... }
  => yield all components

Note - use of this is mildly deprecated in favour of each, events, todos, journals because those won‘t return timezones, and will return Enumerators if called without a block.

Enumerate the top-level calendar components. Yields them if a block is provided, otherwise returns an Enumerator.

This skips components that are only internally meaningful to iCalendar, such as timezone definitions.

Encode the Calendar as a string. The width is the maximum width of the encoded lines, it can be specified, but is better left to the default.

The value of the PRODID field, an unstructured string meant to identify the software which encoded the Calendar data.

The value of the METHOD field. Protocol methods are used when iCalendars are exchanged in a calendar messaging system, such as iTIP or iMIP. When METHOD is not specified, the Calendar object is merely being used to transport a snapshot of some calendar information; without the intention of conveying a scheduling semantic.

Note that this method can‘t be called method, thats already a method of Object.

Check if the protocol method is method

Push a calendar component onto the calendar.


Alias for encode

The iCalendar version multiplied by 10 as an Integer. iCalendar must have a version of 20, and vCalendar must have a version of 10.