Sha256: 34144fdc3b6330c931a955aa8e0ca0610281275ddf81d8b0f1d760b701fe5f9f
Contents?: true
Size: 922 Bytes
Versions: 2
Compression:
Stored size: 922 Bytes
Contents
module AppleNews class Channel include Resource include Links attr_reader :id, :type, :name, :website, :links, :created_at, :modified_at, :default_section def self.current self.new(AppleNews.config.channel_id) end def initialize(id, data = nil) @id = id @url = "/channels/#{id}" data.nil? ? hydrate! : process_data(data) end def default_section Section.new(section_link_id('defaultSection')) end def sections request = Request::Get.new("/channels/#{id}/sections") resp = request.call resp['data'].map do |section| Section.new(section['id'], section) end end def articles(params = {}) request = Request::Get.new("/channels/#{id}/articles") resp = request.call(params) resp['data'].map do |article| Article.new(article['id'], article) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
apple-news-0.1.1 | lib/apple-news/channel.rb |
apple-news-0.1.0 | lib/apple-news/channel.rb |