class Redd::Models::Multireddit

A multi.

Public Class Methods

from_id(client, id) click to toggle source

Create a Multireddit from its path. @param client [APIClient] the api client to initialize the object with @param id [String] the multi's path (with a leading and trailing slash) @return [Multireddit]

# File lib/redd/models/multireddit.rb, line 13
def self.from_id(client, id)
  new(client, path: id)
end

Public Instance Methods

listing(sort, **params) click to toggle source

Get the appropriate listing. @param sort [:hot, :new, :top, :controversial, :comments, :rising, :gilded] the type of

listing

@param params [Hash] a list of params to send with the request @option params [String] :after return results after the given fullname @option params [String] :before return results before the given fullname @option params [Integer] :count the number of items already seen in the listing @option params [1..100] :limit the maximum number of things to return @option params [:hour, :day, :week, :month, :year, :all] :time the time period to consider

when sorting.

@note The option :time only applies to the top and controversial sorts. @return [Listing<Submission>]

# File lib/redd/models/multireddit.rb, line 30
def listing(sort, **params)
  params[:t] = params.delete(:time) if params.key?(:time)
  @client.model(:get, "#{get_attribute(:path)}#{sort}", params)
end

Private Instance Methods

after_initialize() click to toggle source
# File lib/redd/models/multireddit.rb, line 50
def after_initialize
  @attributes[:subreddits].map! do |subreddit|
    Subreddit.new(client, display_name: subreddit[:name])
  end
end
default_loader() click to toggle source
# File lib/redd/models/multireddit.rb, line 56
def default_loader
  @client.get("/api/multi#{@attributes.fetch(:path)}").body[:data]
end