Class: ShareNotify::PushDocument
- Inherits:
-
Object
- Object
- ShareNotify::PushDocument
- Defined in:
- lib/share_notify/push_document.rb
Defined Under Namespace
Classes: OtherProperty, ShareUri
Instance Attribute Summary collapse
-
#contributors ⇒ Object
readonly
Returns the value of attribute contributors.
-
#description ⇒ Object
Returns the value of attribute description.
-
#languages ⇒ Object
Returns the value of attribute languages.
-
#otherProperties ⇒ Object
readonly
Returns the value of attribute otherProperties.
-
#providerUpdatedDateTime ⇒ Object
readonly
Returns the value of attribute providerUpdatedDateTime.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#uris ⇒ Object
readonly
Returns the value of attribute uris.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #add_contributor(contributor) ⇒ Object
- #delete ⇒ Object
-
#initialize(uri, datetime = nil) ⇒ PushDocument
constructor
A new instance of PushDocument.
- #to_share ⇒ Object
- #updated ⇒ Object
- #updated=(time) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(uri, datetime = nil) ⇒ PushDocument
Returns a new instance of PushDocument.
14 15 16 17 18 19 |
# File 'lib/share_notify/push_document.rb', line 14 def initialize(uri, datetime = nil) datetime = (datetime.is_a?(Time) || datetime.is_a?(DateTime)) ? datetime : Time.now @uris = ShareUri.new(uri) @providerUpdatedDateTime = datetime.utc.strftime('%Y-%m-%dT%H:%M:%SZ') @contributors = [] end |
Instance Attribute Details
#contributors ⇒ Object (readonly)
Returns the value of attribute contributors.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def contributors @contributors end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/share_notify/push_document.rb', line 11 def description @description end |
#languages ⇒ Object
Returns the value of attribute languages.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def languages @languages end |
#otherProperties ⇒ Object (readonly)
Returns the value of attribute otherProperties.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def otherProperties @otherProperties end |
#providerUpdatedDateTime ⇒ Object (readonly)
Returns the value of attribute providerUpdatedDateTime.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def providerUpdatedDateTime @providerUpdatedDateTime end |
#publisher ⇒ Object
Returns the value of attribute publisher.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def publisher @publisher end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/share_notify/push_document.rb', line 11 def title @title end |
#uris ⇒ Object (readonly)
Returns the value of attribute uris.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def uris @uris end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/share_notify/push_document.rb', line 3 def version @version end |
Instance Method Details
#add_contributor(contributor) ⇒ Object
41 42 43 44 |
# File 'lib/share_notify/push_document.rb', line 41 def add_contributor(contributor) return false unless contributor.keys.include?(:name) @contributors << contributor end |
#delete ⇒ Object
68 69 70 |
# File 'lib/share_notify/push_document.rb', line 68 def delete @otherProperties = [OtherProperty.new("status", status: ["deleted"])] end |
#to_share ⇒ Object
64 65 66 |
# File 'lib/share_notify/push_document.rb', line 64 def to_share { jsonData: self } end |
#updated ⇒ Object
25 26 27 |
# File 'lib/share_notify/push_document.rb', line 25 def updated @providerUpdatedDateTime end |
#updated=(time) ⇒ Object
30 31 32 33 |
# File 'lib/share_notify/push_document.rb', line 30 def updated=(time) return unless time.respond_to?(:strftime) @providerUpdatedDateTime = time.utc.strftime('%Y-%m-%dT%H:%M:%SZ') end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/share_notify/push_document.rb', line 21 def valid? !(title.nil? || contributors.empty?) end |