2014-03-11 18:31:22 -04:00
|
|
|
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
require File.join(dir, 'httparty')
|
|
|
|
require 'pp'
|
|
|
|
|
|
|
|
class StackExchange
|
|
|
|
include HTTParty
|
|
|
|
base_uri 'api.stackexchange.com'
|
|
|
|
|
|
|
|
def initialize(service, page)
|
2014-05-09 09:40:21 -04:00
|
|
|
@options = { query: {site: service, page: page} }
|
2014-03-11 18:31:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def questions
|
|
|
|
self.class.get("/2.2/questions", @options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def users
|
|
|
|
self.class.get("/2.2/users", @options)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
stack_exchange = StackExchange.new("stackoverflow", 1)
|
|
|
|
pp stack_exchange.questions
|
|
|
|
pp stack_exchange.users
|