Class: Tilia::Dav::Xml::Property::GetLastModified
- Includes:
- Xml::Element
- Defined in:
- lib/tilia/dav/xml/property/get_last_modified.rb
Overview
This property represents the DAV:getlastmodified property.
Defined in: tools.ietf.org/html/rfc4918#section-15.7
Instance Attribute Summary collapse
-
#time ⇒ Object
getTime.
Class Method Summary collapse
-
.xml_deserialize(reader) ⇒ Object
The deserialize method is called during xml parsing.
Instance Method Summary collapse
-
#initialize(time) ⇒ GetLastModified
constructor
Constructor.
-
#xml_serialize(writer) ⇒ Object
The serialize method is called during xml writing.
Constructor Details
#initialize(time) ⇒ GetLastModified
Constructor
20 21 22 23 24 25 26 27 |
# File 'lib/tilia/dav/xml/property/get_last_modified.rb', line 20 def initialize(time) tz = ActiveSupport::TimeZone.new('UTC') if time.is_a?(Time) @time = time.in_time_zone(tz) else @time = tz.at time end end |
Instance Attribute Details
#time ⇒ Object
getTime
15 16 17 |
# File 'lib/tilia/dav/xml/property/get_last_modified.rb', line 15 def time @time end |
Class Method Details
.xml_deserialize(reader) ⇒ Object
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.
72 73 74 |
# File 'lib/tilia/dav/xml/property/get_last_modified.rb', line 72 def self.xml_deserialize(reader) new(Time.zone.parse(reader.parse_inner_tree)) end |
Instance Method Details
#xml_serialize(writer) ⇒ Object
The serialize method is called during xml writing.
It should use the writer argument to encode this object into XML.
Important note: it is not needed to create the parent element. The parent element is already created, and we only have to worry about attributes, child elements and text (if any).
Important note 2: If you are writing any new elements, you are also responsible for closing them.
47 48 49 50 51 |
# File 'lib/tilia/dav/xml/property/get_last_modified.rb', line 47 def xml_serialize(writer) writer.write( Tilia::Http::Util.to_http_date(@time) ) end |