Class: Calendav::Requests::MakeCalendar

Inherits:
Object
  • Object
show all
Defined in:
lib/calendav/requests/make_calendar.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ MakeCalendar

Returns a new instance of MakeCalendar.



14
15
16
# File 'lib/calendav/requests/make_calendar.rb', line 14

def initialize(attributes)
  @attributes = attributes
end

Class Method Details

.callObject



10
11
12
# File 'lib/calendav/requests/make_calendar.rb', line 10

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



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
# File 'lib/calendav/requests/make_calendar.rb', line 18

def call
  Nokogiri::XML::Builder.new do |xml|
    xml["caldav"].mkcalendar(NAMESPACES) do
      xml["dav"].set do
        xml["dav"].prop do
          xml["dav"].displayname display_name

          if description
            xml["caldav"].public_send(
              :"calendar-description", description
            )
          end

          if time_zone
            xml["caldav"].public_send(:"calendar-timezone", time_zone)
          end

          xml["apple"].public_send(:"calendar-color", color) if color

          xml["caldav"].public_send(
            :"supported-calendar-component-set"
          ) do
            xml["caldav"].comp name: "VEVENT"
            xml["caldav"].comp name: "VTODO"
          end
        end
      end
    end
  end
end