Class: CalDAV::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/CalDAV/Calendar.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def color
  @color
end

#ctagObject (readonly)

Returns the value of attribute ctag.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def ctag
  @ctag
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def description
  @description
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def display_name
  @display_name
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def path
  @path
end

#supported_componentsObject (readonly)

Returns the value of attribute supported_components.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def supported_components
  @supported_components
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



8
9
10
# File 'lib/CalDAV/Calendar.rb', line 8

def timezone
  @timezone
end

Class Method Details

.all(client:, home: nil) ⇒ Object

Discovers the calendars in a home collection and returns them as Calendars — the high-level, object-returning entry point. The CalDAV client stays the low-level path for anyone wanting the raw resources. home defaults to the client's discovered calendar-home-set.



22
23
24
# File 'lib/CalDAV/Calendar.rb', line 22

def all(client:, home: nil)
  load(client: client, home: home)
end

.from_resource(resource) ⇒ Object

Builds a Calendar from a CalDAV::Resource (as returned by a calendar-home PROPFIND). Strictly a mapping over the resource's navigation accessors — no parsing. ctag and color are read opportunistically: populated only when the extension accessors are loaded (require 'CalDAV/Objects' pulls them in; 'CalDAV/Objects/Core' does not), and nil otherwise.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/CalDAV/Calendar.rb', line 31

def from_resource(resource)
  new(
    path: resource.href,
    display_name: resource.display_name,
    ctag: (resource.getctag if resource.respond_to?(:getctag)),
    color: (resource.calendar_color if resource.respond_to?(:calendar_color)),
    description: resource.calendar_description,
    timezone: resource.calendar_timezone,
    supported_components: resource.supported_calendar_component_set
  )
end

Instance Method Details

#to_sObject



51
52
53
# File 'lib/CalDAV/Calendar.rb', line 51

def to_s
  display_name || path
end