Class: ShareNotify::PushDocument

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

Defined Under Namespace

Classes: ShareUri

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ PushDocument

Returns a new instance of PushDocument.

Parameters:

  • uri (String)

    that identifies the resource



7
8
9
10
11
# File 'lib/share_notify/push_document.rb', line 7

def initialize(uri)
  @uris = ShareUri.new(uri)
  @providerUpdatedDateTime = Time.now.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

#providerUpdatedDateTimeObject (readonly)

Returns the value of attribute providerUpdatedDateTime.



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

def providerUpdatedDateTime
  @providerUpdatedDateTime
end

#titleObject

Returns the value of attribute title.



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

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



33
34
35
36
# File 'lib/share_notify/push_document.rb', line 33

def add_contributor(contributor)
  return false unless contributor.keys.include?(:name)
  @contributors << contributor
end

#to_shareObject



38
39
40
# File 'lib/share_notify/push_document.rb', line 38

def to_share
  { jsonData: self }
end

#updatedObject



17
18
19
# File 'lib/share_notify/push_document.rb', line 17

def updated
  @providerUpdatedDateTime
end

#updated=(time) ⇒ Object

Parameters:

  • time (DateTime or Time)

    object that can be formatted in to the correct representation



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

def updated=(time)
  return unless time.respond_to?(:strftime)
  @providerUpdatedDateTime = time.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/share_notify/push_document.rb', line 13

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