Class: Tilia::VObject::Component::VEvent
- Inherits:
-
Tilia::VObject::Component
- Object
- Node
- Tilia::VObject::Component
- Tilia::VObject::Component::VEvent
- Defined in:
- lib/tilia/v_object/component/v_event.rb
Overview
VEvent component.
This component contains some additional functionality specific for VEVENT’s.
Constant Summary
Constants inherited from Node
Node::PROFILE_CALDAV, Node::PROFILE_CARDDAV, Node::REPAIR
Instance Attribute Summary
Attributes inherited from Tilia::VObject::Component
Attributes inherited from Node
Instance Method Summary collapse
-
#in_time_range?(start, ending) ⇒ Boolean
Returns true or false depending on if the event falls in the specified time-range.
-
#validation_rules ⇒ array
A simple list of validation rules.
Methods inherited from Tilia::VObject::Component
#[], #[]=, #add, #children, #components, #delete, #destroy, #initialize, #initialize_copy, #json_serialize, #key?, #remove, #select, #serialize, #to_s, #validate, #xml_serialize
Methods inherited from Node
#==, #[], #[]=, #delete, #destroy, #each, #initialize, #json_serialize, #key?, #serialize, #size, #validate, #xml_serialize
Constructor Details
This class inherits a constructor from Tilia::VObject::Component
Instance Method Details
#in_time_range?(start, ending) ⇒ Boolean
Returns true or false depending on if the event falls in the specified time-range. This is used for filtering purposes.
The rules used to determine if an event falls within the specified time-range is based on the CalDAV specification.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tilia/v_object/component/v_event.rb', line 18 def in_time_range?(start, ending) if self['RRULE'] begin it = Tilia::VObject::Recur::EventIterator.new(self, nil, start.time_zone) rescue Tilia::VObject::Recur::NoInstancesException # If we've catched this exception, there are no instances # for the event that fall into the specified time-range. return false end it.fast_forward(start) # We fast-forwarded to a spot where the end-time of the # recurrence instance exceeded the start of the requested # time-range. # # If the starttime of the recurrence did not exceed the # end of the time range as well, we have a match. return false unless it.dt_start return (it.dt_start < ending && it.dt_end > start) end effective_start = self['DTSTART'].date_time(start.time_zone) if self.key?('DTEND') # The DTEND property is considered non inclusive. So for a 3 day # event in july, dtstart and dtend would have to be July 1st and # July 4th respectively. # # See: # http://tools.ietf.org/html/rfc5545#page-54 effective_end = self['DTEND'].date_time(ending.time_zone) elsif self.key?('DURATION') effective_end = effective_start + Tilia::VObject::DateTimeParser.parse_duration(self['DURATION']) elsif !self['DTSTART'].time? effective_end = effective_start + 1.day else effective_end = effective_start end start < effective_end && ending > effective_start end |
#validation_rules ⇒ array
A simple list of validation rules.
This is simply a list of properties, and how many times they either must or must not appear.
Possible values per property:
* 0 - Must not appear.
* 1 - Must appear exactly once.
* + - Must appear at least once.
* * - Can appear any number of times.
* ? - May appear, but not more than once.
It is also possible to specify defaults and severity levels for violating the rule.
See the VEVENT implementation for getValidationRules for a more complex example.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/tilia/v_object/component/v_event.rb', line 77 def validation_rules { 'UID' => 1, 'DTSTAMP' => 1, 'DTSTART' => parent.key?('METHOD') ? '?' : '1', 'CLASS' => '?', 'CREATED' => '?', 'DESCRIPTION' => '?', 'GEO' => '?', 'LAST-MODIFIED' => '?', 'LOCATION' => '?', 'ORGANIZER' => '?', 'PRIORITY' => '?', 'SEQUENCE' => '?', 'STATUS' => '?', 'SUMMARY' => '?', 'TRANSP' => '?', 'URL' => '?', 'RECURRENCE-ID' => '?', 'RRULE' => '?', 'DTEND' => '?', 'DURATION' => '?', 'ATTACH' => '*', 'ATTENDEE' => '*', 'CATEGORIES' => '*', 'COMMENT' => '*', 'CONTACT' => '*', 'EXDATE' => '*', 'REQUEST-STATUS' => '*', 'RELATED-TO' => '*', 'RESOURCES' => '*', 'RDATE' => '*' } end |