Class: RubyYahooAnswersApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_yahoo_answers_api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(appid, debug = false) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/ruby_yahoo_answers_api/client.rb', line 9

def initialize(appid, debug = false)
  self.appid = appid
  self.debug = debug
end

Instance Attribute Details

#appidObject

Returns the value of attribute appid.



7
8
9
# File 'lib/ruby_yahoo_answers_api/client.rb', line 7

def appid
  @appid
end

#debugObject

Returns the value of attribute debug.



7
8
9
# File 'lib/ruby_yahoo_answers_api/client.rb', line 7

def debug
  @debug
end

Instance Method Details

#get_by_category(parameters = {}) ⇒ Object



31
32
33
34
# File 'lib/ruby_yahoo_answers_api/client.rb', line 31

def get_by_category(parameters = {})
  params      = set_params(parameters)
  request("getByCategory?#{params}")
end

#get_by_category_id(id, parameters = {}) ⇒ Object



26
27
28
29
# File 'lib/ruby_yahoo_answers_api/client.rb', line 26

def get_by_category_id(id, parameters = {})
  parameters[:category_id] = id
  get_by_category(parameters)
end

#get_by_category_name(name, parameters = {}) ⇒ Object



21
22
23
24
# File 'lib/ruby_yahoo_answers_api/client.rb', line 21

def get_by_category_name(name, parameters = {})
  parameters[:category_name] = name
  get_by_category(parameters)
end

#get_by_user(user_id, parameters = {}) ⇒ Object



36
37
38
39
40
41
# File 'lib/ruby_yahoo_answers_api/client.rb', line 36

def get_by_user(user_id, parameters = {})
  parameters[:user_id]  = user_id
  params                = set_params(parameters)

  request("getByUser?#{params}")
end

#get_question(question_id) ⇒ Object



43
44
45
46
47
48
# File 'lib/ruby_yahoo_answers_api/client.rb', line 43

def get_question(question_id)
  parameters = {:question_id => question_id}
  params     = set_params(parameters)

  request("getQuestion?#{params}")
end

#question_search(query, parameters = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/ruby_yahoo_answers_api/client.rb', line 14

def question_search(query, parameters = {})
  parameters[:query] = query
  params = set_params(parameters)

  request("questionSearch?#{params}")
end