class Tilia::Dav::Xml::Property::ResourceType

{DAV:}resourcetype property

This class represents the {DAV:}resourcetype property, as defined in:

tools.ietf.org/html/rfc4918#section-15.9

Attributes

value[R]

Returns the values in clark-notation

For example array('{DAV:}collection')

@return array

Public Class Methods

new(resource_types = nil) click to toggle source

Constructor

You can either pass null (for no resourcetype), a string (for a single resourcetype) or an array (for multiple).

The resourcetype must be specified in clark-notation

@param array|string|null resource_type

Calls superclass method
# File lib/tilia/dav/xml/property/resource_type.rb, line 21
def initialize(resource_types = nil)
  resource_types = [] if resource_types.nil?
  resource_types = [resource_types] unless resource_types.is_a?(Array)
  super(resource_types)
end
xml_deserialize(reader) click to toggle source

The deserialize method is called during xml parsing.

This method is called statictly, this is because in theory this method may be used as a type of constructor, or factory method.

Often you want to return an instance of the current class, but you are free to return other data as well.

Important note 2: You are responsible for advancing the reader to the next element. Not doing anything will result in a never-ending loop.

If you just want to skip parsing for this element altogether, you can just call reader.next

reader.parse_inner_tree will parse the entire sub-tree, and advance to the next element.

@param Reader reader @return mixed

Calls superclass method
# File lib/tilia/dav/xml/property/resource_type.rb, line 70
def self.xml_deserialize(reader)
  new(super(reader))
end

Public Instance Methods

add(type) click to toggle source

Adds a resourcetype value to this property

@param string type @return void

# File lib/tilia/dav/xml/property/resource_type.rb, line 46
def add(type)
  @value << type
  @value = @value.uniq
end
is(type) click to toggle source

Checks if the principal contains a certain value

@param string type @return bool

# File lib/tilia/dav/xml/property/resource_type.rb, line 38
def is(type)
  @value.include?(type)
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/resource_type.rb, line 86
def to_html(html)
  tmp = value.map do |value|
    html.xml_name(value)
  end
  tmp.join(', ')
end