class Redditsherpa::Client
Public Class Methods
new()
click to toggle source
# File lib/redditsherpa/client.rb, line 7 def initialize @conn = Faraday.new(:url => 'http://www.reddit.com/') end
Public Instance Methods
get_posts(subreddit)
click to toggle source
# File lib/redditsherpa/client.rb, line 17 def get_posts(subreddit) response = @conn.get do |req| req.url "r/#{subreddit}/.json" req.headers['Content-Type'] = 'application/json' end JSON.parse(response.body, symbolize_names: true) end
search(query)
click to toggle source
# File lib/redditsherpa/client.rb, line 11 def search(query) params = { 'q' => query } response = @conn.get "subreddits/search/.json", params JSON.parse(response.body, symbolize_names: true) end