lib/vpim/property/common.rb in vpim-0.357 vs lib/vpim/property/common.rb in vpim-0.360
- old
+ new
@@ -76,11 +76,11 @@
# there is no ORGANIZER field).
def organizer
organizer = @properties.field('ORGANIZER')
if organizer
- organizer = Icalendar::Address.new(organizer)
+ organizer = Icalendar::Address.decode(organizer)
end
organizer.freeze
end
@@ -126,11 +126,11 @@
# Return an array of attendees, an empty array if there are none. The
# attendees are objects of Icalendar::Address. If +uri+ is specified
# only the return the attendees with this +uri+.
def attendees(uri = nil)
- attendees = @properties.enum_by_name('ATTENDEE').map { |a| Icalendar::Address.new(a).freeze }
+ attendees = @properties.enum_by_name('ATTENDEE').map { |a| Icalendar::Address.decode(a) }
attendees.freeze
if uri
attendees.select { |a| a == uri }
else
attendees
@@ -169,9 +169,144 @@
def attachments
@properties.enum_by_name('ATTACH').map do |f|
attachment = Attachment.decode(f, 'uri', 'FMTTYPE')
end
end
+ end
+
+ end
+
+ module Set
+
+ # Properties common to Vevent, Vtodo, and Vjournal.
+ module Common
+
+ # Set the access class of the component, see Icalendar::Get::Common#access_class.
+ def access_class(token)
+ set_token 'CLASS', ["PUBLIC", "PRIVATE", "CONFIDENTIAL"], "PUBLIC", token
+ end
+
+ # Set the creation time, see Icalendar::Get::Common#created
+ def created(time)
+ set_datetime 'CREATED', time
+ end
+
+ # Set the description, see Icalendar::Get::Common#description.
+ def description(text)
+ set_text 'DESCRIPTION', text
+ end
+
+ # Set the sequence number, see Icalendar::Get::Common#sequence.
+ # is no SEQUENCE; property.
+ def sequence(int)
+ set_integer 'SEQUENCE', int
+ end
+
+ # Set the timestamp, see Icalendar::Get::Common#timestamp.
+ def dtstamp(time)
+ set_datetime 'DTSTAMP', time
+ self
+ end
+
+ # The start time or date, see Icalendar::Get::Common#dtstart.
+ def dtstart(start)
+ set_date_or_datetime 'DTSTART', 'DATE-TIME', start
+ self
+ end
+
+ # Set the last modification time, see Icalendar::Get::Common#lastmod.
+ def lastmod(time)
+ set_datetime 'LAST-MODIFIED', time
+ self
+ end
+
+ # Set the event organizer, an Icalendar::Address, see Icalendar::Get::Common#organizer.
+ #
+ # Without an +adr+ it yields an Icalendar::Address that is a copy of
+ # the current organizer (if any), allowing it to be modified.
+ def organizer(adr=nil) #:yield: organizer
+ unless adr
+ adr = @comp.organizer
+ if adr
+ adr = adr.copy
+ else
+ adr = Icalendar::Address.create
+ end
+ yield adr
+ end
+ set_address('ORGANIZER', adr)
+ self
+ end
+
+=begin
+ # Status values are not rejected during decoding. However, if the
+ # status is requested, and it's value is not one of the defined
+ # allowable values, an exception is raised.
+ def status
+ case self
+ when Vpim::Icalendar::Vevent
+ proptoken 'STATUS', ['TENTATIVE', 'CONFIRMED', 'CANCELLED']
+
+ when Vpim::Icalendar::Vtodo
+ proptoken 'STATUS', ['NEEDS-ACTION', 'COMPLETED', 'IN-PROCESS', 'CANCELLED']
+
+ when Vpim::Icalendar::Vevent
+ proptoken 'STATUS', ['DRAFT', 'FINAL', 'CANCELLED']
+ end
+ end
+=end
+
+ # Set summary description of component, see Icalendar::Get::Common#summary.
+ def summary(text)
+ set_text 'SUMMARY', text
+ end
+
+ # Set the unique identifier of this calendar component, see Icalendar::Get::Common#uid.
+ def uid(uid)
+ set_text 'UID', uid
+ end
+
+ def url(url)
+ set_text 'URL', url
+ end
+
+ # Add an attendee Address, see Icalendar::Get::Common#attendees.
+ def add_attendee(adr)
+ add_address('ATTENDEE', adr)
+ end
+
+ # Set the categories, see Icalendar::Get::Common#attendees.
+ #
+ # If +cats+ is provided, the categories are set to cats, either a
+ # String or an Array of String. Otherwise, and array of the existing
+ # category strings is yielded, and it can be modified.
+ def categories(cats = nil) #:yield: categories
+ unless cats
+ cats = @comp.categories
+ yield cats
+ end
+ # TODO - strip the strings
+ set_text_list('CATEGORIES', cats)
+ end
+
+ # Set the comment, see Icalendar::Get::Common#comment.
+ def comment(value)
+ set_text 'COMMENT', value
+ end
+
+=begin
+ def contacts
+ proptextarray 'CONTACT'
+ end
+
+ # An Array of attachments, see Attachment for more information.
+ def attachments
+ @properties.enum_by_name('ATTACH').map do |f|
+ attachment = Attachment.decode(f, 'uri', 'FMTTYPE')
+ end
+ end
+=end
+
end
end
end
end