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.
13 14 15 16 17 18 19 |
# File 'lib/protocol/caldav/item.rb', line 13 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.
11 12 13 |
# File 'lib/protocol/caldav/item.rb', line 11 def body @body end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
11 12 13 |
# File 'lib/protocol/caldav/item.rb', line 11 def content_type @content_type end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
11 12 13 |
# File 'lib/protocol/caldav/item.rb', line 11 def etag @etag end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/protocol/caldav/item.rb', line 11 def path @path end |
Instance Method Details
#build_propfind(xml) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/protocol/caldav/item.rb', line 25 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
34 35 36 37 38 39 40 41 |
# File 'lib/protocol/caldav/item.rb', line 34 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
43 44 45 46 47 48 49 50 |
# File 'lib/protocol/caldav/item.rb', line 43 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
52 53 54 |
# File 'lib/protocol/caldav/item.rb', line 52 def build_xml(xml) build_propfind(xml) end |
#new? ⇒ Boolean
21 22 23 |
# File 'lib/protocol/caldav/item.rb', line 21 def new? @new_record end |
#to_propfind_xml ⇒ Object
56 57 58 59 60 |
# File 'lib/protocol/caldav/item.rb', line 56 def to_propfind_xml x = Builder::XmlMarkup.new build_propfind(x) x.target! end |
#to_propname_xml ⇒ Object
62 63 64 65 66 |
# File 'lib/protocol/caldav/item.rb', line 62 def to_propname_xml x = Builder::XmlMarkup.new build_propname(x) x.target! end |
#to_report_xml(data_tag:) ⇒ Object
68 69 70 71 72 |
# File 'lib/protocol/caldav/item.rb', line 68 def to_report_xml(data_tag:) x = Builder::XmlMarkup.new build_report(x, data_tag: data_tag) x.target! end |