Class: Protocol::Caldav::Item
- Inherits:
-
Object
- Object
- Protocol::Caldav::Item
- Defined in:
- lib/protocol/caldav/item.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #build_propfind(xml) ⇒ Object
- #build_propname(xml) ⇒ Object
- #build_report(xml, data_tag:) ⇒ Object
- #build_xml(xml) ⇒ Object
-
#initialize(path:, body:, content_type:, etag:, new_record: false) ⇒ Item
constructor
A new instance of Item.
- #new? ⇒ Boolean
- #to_propfind_xml ⇒ Object
- #to_propname_xml ⇒ Object
- #to_report_xml(data_tag:) ⇒ Object
Constructor Details
#initialize(path:, body:, content_type:, etag:, new_record: false) ⇒ Item
Returns a new instance of Item.
11 12 13 14 15 16 17 |
# File 'lib/protocol/caldav/item.rb', line 11 def initialize(path:, body:, content_type:, etag:, new_record: false) @path = path @body = body @content_type = content_type @etag = etag @new_record = new_record end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/protocol/caldav/item.rb', line 9 def body @body end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
9 10 11 |
# File 'lib/protocol/caldav/item.rb', line 9 def content_type @content_type end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
9 10 11 |
# File 'lib/protocol/caldav/item.rb', line 9 def etag @etag end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/protocol/caldav/item.rb', line 9 def path @path end |
Instance Method Details
#build_propfind(xml) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/protocol/caldav/item.rb', line 23 def build_propfind(xml) XmlBuilder.response(xml, href: @path.to_s) do XmlBuilder.propstat_ok(xml) do xml.tag!("d:getetag", @etag) xml.tag!("d:getcontenttype", @content_type) end end end |
#build_propname(xml) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/protocol/caldav/item.rb', line 32 def build_propname(xml) XmlBuilder.response(xml, href: @path.to_s) do XmlBuilder.propstat_ok(xml) do xml.tag!("d:getetag") xml.tag!("d:getcontenttype") end end end |
#build_report(xml, data_tag:) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/protocol/caldav/item.rb', line 41 def build_report(xml, data_tag:) XmlBuilder.response(xml, href: @path.to_s) do XmlBuilder.propstat_ok(xml) do xml.tag!("d:getetag", @etag) xml.tag!(data_tag, @body) end end end |
#build_xml(xml) ⇒ Object
50 51 52 |
# File 'lib/protocol/caldav/item.rb', line 50 def build_xml(xml) build_propfind(xml) end |
#new? ⇒ Boolean
19 20 21 |
# File 'lib/protocol/caldav/item.rb', line 19 def new? @new_record end |
#to_propfind_xml ⇒ Object
54 55 56 57 58 |
# File 'lib/protocol/caldav/item.rb', line 54 def to_propfind_xml x = Builder::XmlMarkup.new build_propfind(x) x.target! end |
#to_propname_xml ⇒ Object
60 61 62 63 64 |
# File 'lib/protocol/caldav/item.rb', line 60 def to_propname_xml x = Builder::XmlMarkup.new build_propname(x) x.target! end |
#to_report_xml(data_tag:) ⇒ Object
66 67 68 69 70 |
# File 'lib/protocol/caldav/item.rb', line 66 def to_report_xml(data_tag:) x = Builder::XmlMarkup.new build_report(x, data_tag: data_tag) x.target! end |