class Tilia::Dav::Xml::Property::SupportedReportSet

supported-report-set property.

This property is defined in RFC3253, but since it's so common in other webdav-related specs, it is part of the core server.

This property is defined here: tools.ietf.org/html/rfc3253#section-3.1.5

Public Class Methods

new(reports = nil) click to toggle source

Creates the property

Any reports passed in the constructor should be valid report-types in clark-notation.

Either a string or an array of strings must be passed.

@param string|string[] reports

# File lib/tilia/dav/xml/property/supported_report_set.rb, line 29
def initialize(reports = nil)
  @reports = []

  add_report(reports) if reports
end

Public Instance Methods

add_report(report) click to toggle source

Adds a report to this property

The report must be a string in clark-notation. Multiple reports can be specified as an array.

@param mixed report @return void

# File lib/tilia/dav/xml/property/supported_report_set.rb, line 42
def add_report(report)
  report = [report] unless report.is_a?(Array)

  report.each do |r|
    unless r =~ /^{([^}]*)}(.*)$/
      fail Dav::Exception, 'Reportname must be in clark-notation'
    end

    @reports << r
  end
end
has(report_name) click to toggle source

Returns true or false if the property contains a specific report.

@param string report_name @return bool

# File lib/tilia/dav/xml/property/supported_report_set.rb, line 65
def has(report_name)
  @reports.include?(report_name)
end
to_html(html) click to toggle source

Generate html representation for this value.

The html output is 100% trusted, and no effort is being made to sanitize it. It's up to the implementor to sanitize user provided values.

The output must be in UTF-8.

The baseUri parameter is a url to the root of the application, and can be used to construct local links.

@param HtmlOutputHelper html @return string

# File lib/tilia/dav/xml/property/supported_report_set.rb, line 108
def to_html(html)
  tmp = value.map do |value|
    html.xml_name(value)
  end
  tmp.join(', ')
end
value() click to toggle source

Returns the list of supported reports

@return string[]

# File lib/tilia/dav/xml/property/supported_report_set.rb, line 57
def value
  @reports
end
xml_serialize(writer) click to toggle source

The xmlSerialize metod is called during xml writing.

Use the writer argument to write its own xml serialization.

An important note: do not create a parent element. Any element implementing XmlSerializble should only ever write what's considered its 'inner xml'.

The parent of the current element is responsible for writing a containing element.

This allows serializers to be re-used for different element names.

If you are opening new elements, you must also close them again.

@param Writer writer @return void

# File lib/tilia/dav/xml/property/supported_report_set.rb, line 86
def xml_serialize(writer)
  value.each do |val|
    writer.start_element('{DAV:}supported-report')
    writer.start_element('{DAV:}report')
    writer.write_element(val)
    writer.end_element
    writer.end_element
  end
end