Class: AppleNews::Channel
- Inherits:
-
Object
- Object
- AppleNews::Channel
- Defined in:
- lib/apple-news/channel.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#default_section ⇒ Object
readonly
Returns the value of attribute default_section.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#modified_at ⇒ Object
readonly
Returns the value of attribute modified_at.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#share_url ⇒ Object
readonly
Returns the value of attribute share_url.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #articles(params = {}) ⇒ Object
-
#initialize(id, data = nil) ⇒ Channel
constructor
A new instance of Channel.
- #sections ⇒ Object
Constructor Details
#initialize(id, data = nil) ⇒ Channel
Returns a new instance of Channel.
13 14 15 16 17 18 |
# File 'lib/apple-news/channel.rb', line 13 def initialize(id, data = nil) @id = id @resource_path = "/channels" data.nil? ? hydrate! : set_read_only_properties(data) end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def created_at @created_at end |
#default_section ⇒ Object (readonly)
Returns the value of attribute default_section.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def default_section @default_section end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def id @id end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def links @links end |
#modified_at ⇒ Object (readonly)
Returns the value of attribute modified_at.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def modified_at @modified_at end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def name @name end |
#share_url ⇒ Object (readonly)
Returns the value of attribute share_url.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def share_url @share_url end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def type @type end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
6 7 8 |
# File 'lib/apple-news/channel.rb', line 6 def website @website end |
Class Method Details
.current ⇒ Object
9 10 11 |
# File 'lib/apple-news/channel.rb', line 9 def self.current self.new(AppleNews.config.channel_id) end |
Instance Method Details
#articles(params = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/apple-news/channel.rb', line 32 def articles(params = {}) request = Request::Get.new("/channels/#{id}/articles") resp = request.call(params) resp['data'].map do |article| Article.new(article['id']) end end |
#sections ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/apple-news/channel.rb', line 24 def sections request = Request::Get.new("/channels/#{id}/sections") resp = request.call resp['data'].map do |section| Section.new(section['id'], section) end end |