Class: AppleNews::Article

Inherits:
Object
  • Object
show all
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 = {}, config = AppleNews.config) ⇒ Article

Returns a new instance of Article.



19
20
21
22
23
24
25
26
27
28
# File 'lib/apple-news/article.rb', line 19

def initialize(id = nil, data = {}, config = AppleNews.config)
  assign_data(data)

  @id = id
  @config = config
  @resource_path = '/articles'
  @files = {}

  hydrate! if id.present? && data.blank?
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#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

#modified_atObject (readonly)

Returns the value of attribute modified_at.



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

def modified_at
  @modified_at
end

#share_urlObject (readonly)

Returns the value of attribute share_url.



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

def share_url
  @share_url
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#warningsObject (readonly)

Returns the value of attribute warnings.



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

def warnings
  @warnings
end

Instance Method Details

#reloadObject



30
31
32
33
# File 'lib/apple-news/article.rb', line 30

def reload
  return false if id.nil?
  hydrate!
end