class Calendav::Requests::ListEvents

Public Class Methods

call(...) click to toggle source
# File lib/calendav/requests/list_events.rb, line 10
def self.call(...)
  new(...).call
end
new(from:, to:) click to toggle source
# File lib/calendav/requests/list_events.rb, line 14
def initialize(from:, to:)
  @from = from
  @to = to
end

Public Instance Methods

call() click to toggle source
# File lib/calendav/requests/list_events.rb, line 19
def call
  Nokogiri::XML::Builder.new do |xml|
    xml["caldav"].public_send("calendar-query", NAMESPACES) do
      xml["dav"].prop do
        xml["dav"].getetag
        xml["caldav"].public_send(:"calendar-data")
      end
      xml["caldav"].filter do
        xml["caldav"].public_send(:"comp-filter", name: "VCALENDAR") do
          xml["caldav"].public_send(:"comp-filter", name: "VEVENT") do
            if range?
              xml["caldav"].public_send(
                :"time-range", start: from, end: to
              )
            end
          end
        end
      end
    end
  end
end

Private Instance Methods

from() click to toggle source
# File lib/calendav/requests/list_events.rb, line 43
def from
  return nil if @from.nil?

  @from.utc.iso8601.delete(":-")
end
range?() click to toggle source
# File lib/calendav/requests/list_events.rb, line 55
def range?
  to || from
end
to() click to toggle source
# File lib/calendav/requests/list_events.rb, line 49
def to
  return nil if @to.nil?

  @to.utc.iso8601.delete(":-")
end