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
-
#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.
12 13 14 15 16 17 18 |
# File 'lib/protocol/caldav/item.rb', line 12 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.
10 11 12 |
# File 'lib/protocol/caldav/item.rb', line 10 def body @body end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
10 11 12 |
# File 'lib/protocol/caldav/item.rb', line 10 def content_type @content_type end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
10 11 12 |
# File 'lib/protocol/caldav/item.rb', line 10 def etag @etag end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/protocol/caldav/item.rb', line 10 def path @path end |
Instance Method Details
#new? ⇒ Boolean
20 21 22 |
# File 'lib/protocol/caldav/item.rb', line 20 def new? @new_record end |
#to_propfind_xml ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/protocol/caldav/item.rb', line 24 def to_propfind_xml <<~XML <d:response> <d:href>#{Xml.escape(@path.to_s)}</d:href> <d:propstat> <d:prop> <d:getetag>#{Xml.escape(@etag)}</d:getetag> <d:getcontenttype>#{Xml.escape(@content_type)}</d:getcontenttype> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> XML end |
#to_propname_xml ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/protocol/caldav/item.rb', line 39 def to_propname_xml <<~XML <d:response> <d:href>#{Xml.escape(@path.to_s)}</d:href> <d:propstat> <d:prop> <d:getetag/> <d:getcontenttype/> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> XML end |
#to_report_xml(data_tag:) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/protocol/caldav/item.rb', line 54 def to_report_xml(data_tag:) <<~XML <d:response> <d:href>#{Xml.escape(@path.to_s)}</d:href> <d:propstat> <d:prop> <d:getetag>#{Xml.escape(@etag)}</d:getetag> <#{data_tag}>#{Xml.escape(@body)}</#{data_tag}> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> XML end |