class Redd::Models::FrontPage

The front page. FIXME: deal with serious code duplication from Subreddit

Public Instance Methods

comment_stream(**params, &block) click to toggle source

Stream newly submitted comments.

# File lib/redd/models/front_page.rb, line 65
def comment_stream(**params, &block)
  params[:limit] ||= 100
  stream = Utilities::Stream.new do |previous|
    before = previous ? previous.first.name : nil
    listing(:comments, params.merge(before: before))
  end
  block_given? ? stream.stream(&block) : stream.enum_for(:stream)
end
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/front_page.rb, line 36
def listing(sort, **params)
  params[:t] = params.delete(:time) if params.key?(:time)
  @client.model(:get, "/#{sort}", params)
end
post_stream(**params, &block) click to toggle source

Stream newly submitted posts.

# File lib/redd/models/front_page.rb, line 55
def post_stream(**params, &block)
  params[:limit] ||= 100
  stream = Utilities::Stream.new do |previous|
    before = previous ? previous.first.name : nil
    listing(:new, params.merge(before: before))
  end
  block_given? ? stream.stream(&block) : stream.enum_for(:stream)
end
wiki_page(title) click to toggle source

Get a wiki page by its title. @param title [String] the page's title @return [WikiPage]

# File lib/redd/models/front_page.rb, line 19
def wiki_page(title)
  WikiPage.new(@client, title: title)
end
wiki_pages() click to toggle source

@return [Array<String>] reddit's base wiki pages

# File lib/redd/models/front_page.rb, line 12
def wiki_pages
  @client.get('/wiki/pages').body[:data]
end