Class: Sapphire::RestClientReddit
- Inherits:
-
Object
- Object
- Sapphire::RestClientReddit
- Defined in:
- lib/apiclients/restclient.rb
Constant Summary collapse
- BASE_URL =
'https://www.reddit.com'
Instance Method Summary collapse
- #get_posts(subreddit) ⇒ Object
-
#initialize ⇒ RestClientReddit
constructor
A new instance of RestClientReddit.
Constructor Details
#initialize ⇒ RestClientReddit
Returns a new instance of RestClientReddit.
7 8 9 |
# File 'lib/apiclients/restclient.rb', line 7 def initialize @headers = { params: { limit: 10, sort: 'hot' } } end |
Instance Method Details
#get_posts(subreddit) ⇒ Object
11 12 13 14 15 |
# File 'lib/apiclients/restclient.rb', line 11 def get_posts(subreddit) url = "#{BASE_URL}/r/#{subreddit}/hot.json" response = RestClient.get(url, @headers) parse_response(response) end |