Class: AppleNews::Article

Inherits:
Object
  • Object
show all
Includes:
Properties, Resource
Defined in:
lib/apple-news/article.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (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?

Returns:

  • (Boolean)


28
29
30
# File 'lib/apple-news/article.rb', line 28

def persisted?
  !@id.nil?
end