Class: Rubyoverflow::Users

Inherits:
PagedBase show all
Defined in:
lib/rubyoverflow/users.rb

Instance Attribute Summary collapse

Attributes inherited from PagedBase

#page, #pagesize, #query_parameters, #request_path, #total

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PagedBase

#next_page_parameters, #perform_next_page_request

Methods inherited from Base

change_end_point, client, convert_if_array, convert_to_id_list, #find_parse_querystring, request, #request

Constructor Details

#initialize(hash, request_path = '') ⇒ Users

Returns a new instance of Users.



5
6
7
8
9
10
11
12
13
# File 'lib/rubyoverflow/users.rb', line 5

def initialize(hash, request_path = '')
  dash = UsersDash.new hash
  super(dash, request_path)
  @users = Array.new

  dash.users.each{|userHash| @users.push(User.new userHash)} if dash.users
  dash.associated_users.each{|userHash| @users.push(User.new userHash)} if dash.associated_users
  
end

Instance Attribute Details

#usersObject (readonly)

Returns the value of attribute users.



3
4
5
# File 'lib/rubyoverflow/users.rb', line 3

def users
  @users
end

Class Method Details

.retrieve_all(parameters = {}) ⇒ Object

Retieves all users using the parameters provided

Maps to ‘/users’



26
27
28
29
# File 'lib/rubyoverflow/users.rb', line 26

def retrieve_all(parameters = {})
  hash,url = request('users/', parameters)
  Users.new hash, url
end

.retrieve_associated_accounts(guid) ⇒ Object



61
62
63
64
65
# File 'lib/rubyoverflow/users.rb', line 61

def retrieve_associated_accounts(guid)
  client = Client.stackauth_client(Base.client.api_key)
  hash,url = client.request('users/' + guid +'/associated',{})
  Users.new hash,url
end

.retrieve_by_badge(id, parameters = {}) ⇒ Object

Retrieves users that have received badge(s) by badge id(s) using the parameters provided

id can be an int, string, badge or an array of any of the three

Maps to ‘/badges/id’



47
48
49
50
51
# File 'lib/rubyoverflow/users.rb', line 47

def retrieve_by_badge(id, parameters = {})
  id = convert_to_id_list(id)
  hash,url = request('badges/'+id.to_s, parameters)
  Users.new hash, url
end

.retrieve_by_id(id, parameters = {}) ⇒ Object

Retrieves users by id(s) using the parameters provided

id can be an int, string, or an array of either

Maps to ‘/users/id’



36
37
38
39
40
# File 'lib/rubyoverflow/users.rb', line 36

def retrieve_by_id(id, parameters = {})
  id = convert_to_id_list(id)
  hash,url = request('users/'+id.to_s, parameters)
  Users.new hash, url
end

.retrieve_moderators(parameters = {}) ⇒ Object

Retrieves moderators for the current site the parameters provided

Maps to ‘/users/moderators’



56
57
58
59
# File 'lib/rubyoverflow/users.rb', line 56

def retrieve_moderators(parameters = {})
  hash,url = request('users/moderators', parameters)
  Users.new hash, url
end

Instance Method Details

#get_next_setObject

Retrieves the next set of users using the same parameters used to retrieve the current set



16
17
18
19
# File 'lib/rubyoverflow/users.rb', line 16

def get_next_set
  hash,url = perform_next_page_request
  Users.new hash,url
end