Class: AppleNews::Article

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Attachments, Persistence, Properties, Resource
Defined in:
lib/apple-news/article.rb,
lib/apple-news/article/attachments.rb,
lib/apple-news/article/persistence.rb

Defined Under Namespace

Modules: Attachments, Persistence

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Properties

#load_properties

Constructor Details

#initialize(id = nil, data = {}) ⇒ Article

Returns a new instance of Article.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/apple-news/article.rb', line 20

def initialize(id = nil, data = {})
  super(data)

  @resource_path = "/articles"
  @id = id

  document = (data[:document] || data['document'])
  @document = document.is_a?(AppleNews::Document) ? document : Document.new(document)
  @files = {}

  # These are read-only properties that are not submitted to the API
  @share_url = data['shareUrl']
  @state = data['state']

  hydrate! if !id.nil? && data.keys.size == 0
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



17
18
19
# File 'lib/apple-news/article.rb', line 17

def document
  @document
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/apple-news/article.rb', line 16

def id
  @id
end