Class: Stackexchange::Client

Inherits:
Object
  • Object
show all
Includes:
APISmith::Client
Defined in:
lib/stackexchange-ruby.rb

Constant Summary collapse

METHODS =
%w[answers questions badges comments events info posts priviligess search tags]

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Client

api_key



11
12
13
14
15
16
17
18
19
# File 'lib/stackexchange-ruby.rb', line 11

def initialize(*args)
  add_query_options! :api_key => args.shift, :site => 'stackoverflow'

  METHODS.each do |m|
    self.class.send(:define_method, m) do |*opts|
      resp = (get "#{m}", :extra_query => opts.shift)
    end
  end
end