Class: Vpim::Icalendar::Vevent
- Inherits:
-
Object
- Object
- Vpim::Icalendar::Vevent
- Includes:
- Property::Base, Property::Common, Property::Location, Property::Priority, Property::Recurrence, Property::Resources
- Defined in:
- lib/vpim/vevent.rb
Defined Under Namespace
Classes: Maker
Class Method Summary collapse
-
.create(start = Time.now, fields = []) ⇒ Object
Create a new Vevent object.
-
.create_yearly(date, summary) ⇒ Object
Creates a yearly repeating event, such as for a birthday.
Instance Method Summary collapse
-
#accept(invitee) ⇒ Object
Accept an event invitation.
-
#dtend ⇒ Object
The end time for this Event.
-
#duration ⇒ Object
The duration in seconds of an Event, or nil if unspecified.
-
#fields ⇒ Object
TODO - derive everything from Icalendar::Component to get rid of this kind of stuff?.
-
#initialize(fields) ⇒ Vevent
constructor
:nodoc:.
-
#properties ⇒ Object
:nodoc:.
-
#transparency ⇒ Object
In iTIP, whether this event is OPAQUE or TRANSPARENT to scheduling.
Methods included from Property::Recurrence
#occurrences, #occurs_in?, #rdates, #rrule
Methods included from Property::Resources
Methods included from Property::Location
Methods included from Property::Priority
Methods included from Property::Common
#access_class, #attachments, #attendee?, #attendees, #categories, #comments, #contacts, #created, #description, #dtstamp, #dtstart, #lastmod, #organizer, #sequence, #status, #summary, #uid, #url
Methods included from Property::Base
#propduration, #propend, #propinteger, #proptext, #proptextarray, #proptextlistarray, #proptime, #proptoken, #propvalue, #propvaluearray
Constructor Details
#initialize(fields) ⇒ Vevent
:nodoc:
33 34 35 36 37 38 39 40 41 |
# File 'lib/vpim/vevent.rb', line 33 def initialize(fields) #:nodoc: outer, inner = Vpim.outer_inner(fields) @properties = Vpim::DirectoryInfo.create(outer) @elements = inner # See "TODO - fields" in dirinfo.rb end |
Class Method Details
.create(start = Time.now, fields = []) ⇒ Object
Create a new Vevent object. All events must have a DTSTART field, specify it as either a Time or a Date in start
, it defaults to “now”
If specified, fields
must be either an array of Field objects to add, or a Hash of String names to values that will be used to build Field objects. The latter is a convenient short-cut allowing the Field objects to be created for you when called like:
Vevent.create(Date.today, 'SUMMARY' => "today's event")
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vpim/vevent.rb', line 65 def Vevent.create(start = Time.now, fields=[]) # TODO # - maybe events are usually created in a particular way? With a # start/duration or a start/end? Maybe I can make it easier. Ideally, I # would like to make it hard to encode an invalid Event. # - I don't think its useful to have a default dtstart for events # - also, I don't think dstart is mandatory dtstart = DirectoryInfo::Field.create('DTSTART', start) di = DirectoryInfo.create([ dtstart ], 'VEVENT') Vpim::DirectoryInfo::Field.create_array(fields).each { |f| di.push_unique f } new(di.to_a) end |
.create_yearly(date, summary) ⇒ Object
Creates a yearly repeating event, such as for a birthday.
81 82 83 84 85 86 87 |
# File 'lib/vpim/vevent.rb', line 81 def Vevent.create_yearly(date, summary) create( date, 'SUMMARY' => summary.to_str, 'RRULE' => 'FREQ=YEARLY' ) end |
Instance Method Details
#accept(invitee) ⇒ Object
Accept an event invitation. The invitee
is the Address that wishes to accept the event invitation as confirmed.
The event created is identical to this one, but
-
without the attendees
-
with the invitee added with a PARTSTAT of ACCEPTED
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/vpim/vevent.rb', line 95 def accept(invitee) # FIXME - move to Vpim::Itip. invitee = invitee.copy invitee.partstat = 'ACCEPTED' fields = [] @properties.each_with_index do |f,i| # put invitee in as field[1] fields << invitee.encode('ATTENDEE') if i == 1 fields << f unless f.name? 'ATTENDEE' end Vevent.new(fields) end |
#dtend ⇒ Object
The end time for this Event. If the DTEND field is not present, but the DURATION field is, the end will be calculated from DTSTART and DURATION.
131 132 133 |
# File 'lib/vpim/vevent.rb', line 131 def dtend propend 'DTEND' end |
#duration ⇒ Object
The duration in seconds of an Event, or nil if unspecified. If the DURATION field is not present, but the DTEND field is, the duration is calculated from DTSTART and DTEND. Durations of zero seconds are possible.
124 125 126 |
# File 'lib/vpim/vevent.rb', line 124 def duration propduration 'DTEND' end |
#fields ⇒ Object
TODO - derive everything from Icalendar::Component to get rid of this kind of stuff?
44 45 46 47 48 49 |
# File 'lib/vpim/vevent.rb', line 44 def fields #:nodoc: f = @properties.to_a last = f.pop f.push @elements f.push last end |
#properties ⇒ Object
:nodoc:
51 52 53 |
# File 'lib/vpim/vevent.rb', line 51 def properties #:nodoc: @properties end |
#transparency ⇒ Object
In iTIP, whether this event is OPAQUE or TRANSPARENT to scheduling. If transparency is not explicitly set, it defaults to OPAQUE.
116 117 118 |
# File 'lib/vpim/vevent.rb', line 116 def transparency proptoken 'TRANSP', ["OPAQUE", "TRANSPARENT"], "OPAQUE" end |