Class: Tilia::Dav::Xml::Property::SupportedReportSet
- Includes:
- Browser::HtmlOutput, Xml::XmlSerializable
- Defined in:
- lib/tilia/dav/xml/property/supported_report_set.rb
Overview
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
Instance Method Summary collapse
-
#add_report(report) ⇒ Object
Adds a report to this property.
-
#has(report_name) ⇒ Object
Returns true or false if the property contains a specific report.
-
#initialize(reports = nil) ⇒ SupportedReportSet
constructor
Creates the property.
-
#to_html(html) ⇒ Object
Generate html representation for this value.
-
#value ⇒ Object
Returns the list of supported reports.
-
#xml_serialize(writer) ⇒ Object
The xmlSerialize metod is called during xml writing.
Constructor Details
#initialize(reports = nil) ⇒ SupportedReportSet
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.
29 30 31 32 33 |
# File 'lib/tilia/dav/xml/property/supported_report_set.rb', line 29 def initialize(reports = nil) @reports = [] add_report(reports) if reports end |
Instance Method Details
#add_report(report) ⇒ Object
Adds a report to this property
The report must be a string in clark-notation. Multiple reports can be specified as an array.
42 43 44 45 46 47 48 49 50 51 52 |
# 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) ⇒ Object
Returns true or false if the property contains a specific report.
65 66 67 |
# File 'lib/tilia/dav/xml/property/supported_report_set.rb', line 65 def has(report_name) @reports.include?(report_name) end |
#to_html(html) ⇒ Object
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.
108 109 110 111 112 113 |
# 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 ⇒ Object
Returns the list of supported reports
57 58 59 |
# File 'lib/tilia/dav/xml/property/supported_report_set.rb', line 57 def value @reports end |
#xml_serialize(writer) ⇒ Object
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.
86 87 88 89 90 91 92 93 94 |
# 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 |