class Calendav::Parsers::EventXML

Attributes

element[R]

Public Class Methods

call(...) click to toggle source
# File lib/calendav/parsers/event_xml.rb, line 6
def self.call(...)
  new(...).call
end
new(element) click to toggle source
# File lib/calendav/parsers/event_xml.rb, line 10
def initialize(element)
  @element = element
end

Public Instance Methods

call() click to toggle source
# File lib/calendav/parsers/event_xml.rb, line 14
def call
  {
    calendar_data: value(".//caldav:calendar-data"),
    etag: value(".//dav:getetag")
  }
end

Private Instance Methods

value(xpath) click to toggle source
# File lib/calendav/parsers/event_xml.rb, line 25
def value(xpath)
  node = element.xpath(xpath)
  return nil if node.children.empty?

  if node.children.any?(&:element?)
    node.children.select(&:element?).collect(&:to_xml).join
  else
    node.children.text
  end
end