class Theguardian::Api::Section

Public Class Methods

process(params = {}) click to toggle source
# File lib/theguardian/api/section.rb, line 4
def self.process(params = {})
        connection = Theguardian::Connection.new(resource: params[:id] || "sections")
        response = connection.get

        if params[:id]
                self.new(response, recurse_over_arrays: true)
        else
                response["results"].map do |section_params|
                        self.new(section_params, recurse_over_arrays: true)
                end
        end
end
process_params(params) click to toggle source
# File lib/theguardian/api/section.rb, line 27
def self.process_params(params)
        params.reject{ |_, value| value.nil? }
end

Public Instance Methods

fetch() click to toggle source
# File lib/theguardian/api/section.rb, line 23
def fetch
        self.class.process(id: self.id)
end
items() click to toggle source
# File lib/theguardian/api/section.rb, line 17
def items
        self.results.map do |item_params|
                Theguardian::Api::Item.new(item_params, recurse_over_arrays: true)
        end
end