Class: ShareNotify::PushDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/share_notify/push_document.rb

Defined Under Namespace

Classes: OtherProperty, ShareUri

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, datetime = nil) ⇒ PushDocument

Returns a new instance of PushDocument.

Parameters:

  • uri (String)

    that identifies the resource



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

#contributorsObject (readonly)

Returns the value of attribute contributors.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def contributors
  @contributors
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/share_notify/push_document.rb', line 11

def description
  @description
end

#languagesObject

Returns the value of attribute languages.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def languages
  @languages
end

#otherPropertiesObject (readonly)

Returns the value of attribute otherProperties.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def otherProperties
  @otherProperties
end

#providerUpdatedDateTimeObject (readonly)

Returns the value of attribute providerUpdatedDateTime.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def providerUpdatedDateTime
  @providerUpdatedDateTime
end

#publisherObject

Returns the value of attribute publisher.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def publisher
  @publisher
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



11
12
13
# File 'lib/share_notify/push_document.rb', line 11

def title
  @title
end

#urisObject (readonly)

Returns the value of attribute uris.



3
4
5
# File 'lib/share_notify/push_document.rb', line 3

def uris
  @uris
end

#versionObject

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

Parameters:

  • contributor (Hash)

    containing required keys for description



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

#deleteObject



68
69
70
# File 'lib/share_notify/push_document.rb', line 68

def delete
  @otherProperties = [OtherProperty.new("status", status: ["deleted"])]
end

#to_shareObject



64
65
66
# File 'lib/share_notify/push_document.rb', line 64

def to_share
  { jsonData: self }
end

#updatedObject



25
26
27
# File 'lib/share_notify/push_document.rb', line 25

def updated
  @providerUpdatedDateTime
end

#updated=(time) ⇒ Object

Parameters:

  • time (DateTime or Time)

    object that can be formatted in to the correct representation



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

Returns:

  • (Boolean)


21
22
23
# File 'lib/share_notify/push_document.rb', line 21

def valid?
  !(title.nil? || contributors.empty?)
end