Class: Tilia::VObject::Component::VJournal

Inherits:
Tilia::VObject::Component show all
Defined in:
lib/tilia/v_object/component/v_journal.rb

Overview

VJournal component.

This component contains some additional functionality specific for VJOURNALs.

Constant Summary

Constants inherited from Node

Node::PROFILE_CALDAV, Node::PROFILE_CARDDAV, Node::REPAIR

Instance Attribute Summary

Attributes inherited from Tilia::VObject::Component

#name

Attributes inherited from Node

#iterator, #parent

Instance Method Summary collapse

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.

Parameters:

  • start (Time)
  • end (Time)

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tilia/v_object/component/v_journal.rb', line 18

def in_time_range?(start, ending)
  dtstart = key?('DTSTART') ? self['DTSTART'].date_time : nil
  if dtstart
    effective_end = dtstart
    effective_end += 1.day unless self['DTSTART'].time?

    return start <= effective_end && ending > dtstart
  end

  false
end

#validation_rulesarray

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.

Returns:

  • (array)


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
# File 'lib/tilia/v_object/component/v_journal.rb', line 31

def validation_rules
  {
    'UID'     => 1,
    'DTSTAMP' => 1,

    'CLASS'         => '?',
    'CREATED'       => '?',
    'DTSTART'       => '?',
    'LAST-MODIFIED' => '?',
    'ORGANIZER'     => '?',
    'RECURRENCE-ID' => '?',
    'SEQUENCE'      => '?',
    'STATUS'        => '?',
    'SUMMARY'       => '?',
    'URL'           => '?',

    'RRULE' => '?',

    'ATTACH'      => '*',
    'ATTENDEE'    => '*',
    'CATEGORIES'  => '*',
    'COMMENT'     => '*',
    'CONTACT'     => '*',
    'DESCRIPTION' => '*',
    'EXDATE'      => '*',
    'RELATED-TO'  => '*',
    'RDATE'       => '*'
  }
end