Class: AppleNews::Section
- Inherits:
-
Object
- Object
- AppleNews::Section
- Defined in:
- lib/apple-news/section.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_default ⇒ Object
readonly
Returns the value of attribute is_default.
-
#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.
Instance Method Summary collapse
- #articles(params = {}) ⇒ Object
- #channel ⇒ Object
-
#initialize(id, data = nil) ⇒ Section
constructor
A new instance of Section.
Constructor Details
#initialize(id, data = nil) ⇒ Section
Returns a new instance of Section.
8 9 10 11 12 13 |
# File 'lib/apple-news/section.rb', line 8 def initialize(id, data = nil) @id = id @resource_path = "/sections" 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/section.rb', line 6 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/apple-news/section.rb', line 6 def id @id end |
#is_default ⇒ Object (readonly)
Returns the value of attribute is_default.
6 7 8 |
# File 'lib/apple-news/section.rb', line 6 def is_default @is_default end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
6 7 8 |
# File 'lib/apple-news/section.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/section.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/section.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/section.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/section.rb', line 6 def type @type end |
Instance Method Details
#articles(params = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/apple-news/section.rb', line 19 def articles(params = {}) request = Request::Get.new("/sections/#{id}/articles") resp = request.call(params) resp['data'].map do |article| Article.new(article['id']) end end |
#channel ⇒ Object
15 16 17 |
# File 'lib/apple-news/section.rb', line 15 def channel Channel.new(channel_link_id('channel')) end |