Class: RedditApi::Subreddits

Inherits:
Object
  • Object
show all
Defined in:
lib/reddit_api/subreddits.rb

Instance Method Summary collapse

Constructor Details

#initializeSubreddits

Returns a new instance of Subreddits.



5
6
7
8
9
# File 'lib/reddit_api/subreddits.rb', line 5

def initialize
  @client = RedditApi::Client.new
  @subreddit_factory = RedditApi::Subreddit
  @query_factory =  RedditApi::Query
end

Instance Method Details

#data_for(subreddit_name) ⇒ Object



16
17
18
19
20
# File 'lib/reddit_api/subreddits.rb', line 16

def data_for(subreddit_name)
  query = build_singular_query(subreddit_name)
  client.get(query)
  build_subreddit(query.captured_records.first)
end

#top(count) ⇒ Object



11
12
13
14
# File 'lib/reddit_api/subreddits.rb', line 11

def top(count)
  subreddits_data = top_data(count)
  build_all_subreddits(subreddits_data)
end