Class: AppleNews::Article
- Inherits:
-
Object
- Object
- AppleNews::Article
- 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
-
#document ⇒ Object
Returns the value of attribute document.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#share_url ⇒ Object
readonly
Returns the value of attribute share_url.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(id = nil, data = {}) ⇒ Article
constructor
A new instance of Article.
- #reload ⇒ Object
Methods included from 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
#document ⇒ Object
Returns the value of attribute document.
17 18 19 |
# File 'lib/apple-news/article.rb', line 17 def document @document end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/apple-news/article.rb', line 16 def id @id end |
#share_url ⇒ Object (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 |
#state ⇒ Object (readonly)
Returns the value of attribute state.
16 17 18 |
# File 'lib/apple-news/article.rb', line 16 def state @state end |
Instance Method Details
#reload ⇒ Object
37 38 39 40 |
# File 'lib/apple-news/article.rb', line 37 def reload return false if id.nil? hydrate! end |