Parent

Vpim::Icalendar::Address

Used to represent calendar fields containing CAL-ADDRESS values. The organizer or the attendees of a calendar event are examples of such a field.

Example:

ORGANIZER;CN="A. Person":mailto:a_person@example.com

ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION
 ;CN="Sam Roberts";RSVP=TRUE:mailto:SRoberts@example.com

Attributes

cn[RW]

The common or displayable name associated with the calendar address, or nil if there is none.

partstat[RW]

The participation status for the calendar user specified by the property PARTSTAT, a String.

These are the participation statuses for an Event:

  • NEEDS-ACTION Event needs action

  • ACCEPTED Event accepted

  • DECLINED Event declined

  • TENTATIVE Event tentatively accepted

  • DELEGATED Event delegated

Default is NEEDS-ACTION.

FIXME - make the default depend on the component type.

role[RW]

The participation role for the calendar user specified by the address.

The standard roles are:

  • CHAIR Indicates chair of the calendar entity

  • REQ-PARTICIPANT Indicates a participant whose participation is required

  • OPT-PARTICIPANT Indicates a participant whose participation is optional

  • NON-PARTICIPANT Indicates a participant who is copied for information purposes only

The default role is REQ-PARTICIPANT, returned if no ROLE parameter was specified.

rsvp[RW]

The value of the RSVP field, either true or false. It is used to specify whether there is an expectation of a reply from the calendar user specified by the property value.

uri[RW]

Addresses in a CAL-ADDRESS are represented as a URI, usually a mailto URI.

Public Class Methods

create(uri='') click to toggle source

Create a new Address. It will encode as a name property.

# File lib/vpim/address.rb, line 116
def self.create(uri='')
  adr = new
  adr.uri = uri.to_str
  adr
end
decode(field) click to toggle source
# File lib/vpim/address.rb, line 122
def self.decode(field)
  adr = new(field)
  adr.uri = field.value

  cn = field.param('CN')

  if cn
    adr.cn = cn.first
  end

  role = field.param('ROLE')

  if role
    adr.role = role.first.strip.upcase
  end

  partstat = field.param('PARTSTAT')

  if partstat
    adr.partstat = partstat.first.strip.upcase
  end

  rsvp = field.param('RSVP')

  if rsvp
    adr.rsvp = case rsvp.first
               when /TRUE/ then true
               when /FALSE/ then false
               else raise InvalidEncodingError, "RSVP param value not TRUE/FALSE: #{rsvp}"
               end
  end

  adr.freeze
end

Public Instance Methods

==(uri) click to toggle source

Return true if the uri is == to this address’ URI. The comparison is case-insensitive (because email addresses and domain names are).

# File lib/vpim/address.rb, line 195
def ==(uri)
  # TODO - could I use a URI library?
  Vpim::Methods.casecmp?(self.uri.to_str, uri.to_str)
end
copy() click to toggle source

Create a copy of Address. If the original Address was frozen, this one won’t be.

# File lib/vpim/address.rb, line 61
def copy
  #Marshal.load(Marshal.dump(self))
  self.dup.dirty
end
to_s() click to toggle source

A string representation of an address, using the common name, and the URI. The URI protocol is stripped if it’s “mailto:”.

# File lib/vpim/address.rb, line 202
def to_s
  u = uri
  u = u.gsub(/^mailto: */, '')

  if cn.length > 0
    "#{cn.inspect} <#{uri}>"
  else
    uri
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.