Class: AppleNews::Article
- Inherits:
-
Object
- Object
- AppleNews::Article
- Includes:
- Properties, Resource
- Defined in:
- lib/apple-news/article.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id = nil, opts = nil) ⇒ Article
constructor
A new instance of Article.
- #persisted? ⇒ Boolean (also: #saved?)
Constructor Details
#initialize(id = nil, opts = nil) ⇒ Article
Returns a new instance of Article.
18 19 20 21 22 23 24 25 26 |
# File 'lib/apple-news/article.rb', line 18 def initialize(id = nil, opts = nil) super(opts) @id = id @url = "/articles/#{id}" @metadata = Metadata.new((opts || {}).fetch(:metadata, {})) hydrate! if !id.nil? && opts.nil? end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/apple-news/article.rb', line 6 def id @id end |
Instance Method Details
#persisted? ⇒ Boolean Also known as: saved?
28 29 30 |
# File 'lib/apple-news/article.rb', line 28 def persisted? !@id.nil? end |