Sha256: 9f0007f0fe3696ca3a2626881e846606713c58dac855039b6abcb410d6abda04
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Reddit # The main reddit or a subreddit. class Reddit < ResourceList # Initialize the reddit. If no name is specified, the reddit will be the main reddit. def initialize(name = nil) @name = name @url = @name.nil? ? BASE_URL : SUBREDDIT_URL.gsub('[subreddit]', @name) end def hot(options = {}) articles 'hot', options end def top(options = {}) articles 'top', options end def new(options = {}) options[:querystring] = 'sort=new' articles 'new', options end def rising(options = {}) options[:querystring] = 'sort=rising' articles 'new', options end def controversial(options = {}) articles 'controversial', options end # Returns the articles found in this reddit. # Options are: # Count: Return at least this many articles. # Querystring: Querystring to append to resource request def articles(page = 'hot', options = {}) get_resources("#{@url}#{page}", options) do |resource_json| Article.new(resource_json['data']) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bterlson-reddit-0.3.0 | lib/reddit/reddit.rb |