Sha256: 91c90d3954d04c6c8d90747b299f65ccded3aa39b00e7150d905af51195d067f

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

module AppleNews
  class Section
    include Resource
    include Links

    attr_reader :id, :type, :name, :is_default, :links, :created_at, :modified_at

    def initialize(id, data = nil)
      @id = id
      @url = "/sections/#{id}"

      data.nil? ? hydrate! : process_data(data)
    end

    def channel
      Channel.new(channel_link_id('channel'))
    end

    def articles(params = {})
      request = Request::Get.new("/sections/#{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/section.rb
apple-news-0.1.0 lib/apple-news/section.rb