Class: Rubyoverflow::Badges

Inherits:
PagedBase show all
Defined in:
lib/rubyoverflow/badges.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 = '') ⇒ Badges

Returns a new instance of Badges.



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

def initialize(hash, request_path = '')
  dash = BadgesDash.new hash

  @badges = Array.new
  dash.badges.each{ |badgeHash| @badges.push(Badge.new badgeHash)}

  super(dash, request_path)
end

Instance Attribute Details

#badgesObject (readonly)

Returns the value of attribute badges.



4
5
6
# File 'lib/rubyoverflow/badges.rb', line 4

def badges
  @badges
end

Class Method Details

.retrieve_allObject

Retrieves all badges in alphabetical order

Maps to ‘/badges’



19
20
21
22
# File 'lib/rubyoverflow/badges.rb', line 19

def retrieve_all
  hash, url = request('badges')
  Badges.new hash, url
end

.retrieve_all_non_tag_basedObject

Retrieves all standard, non-tag-based badges in alphabetical order

Maps to ‘/badges/name’



27
28
29
30
# File 'lib/rubyoverflow/badges.rb', line 27

def retrieve_all_non_tag_based
  hash, url = request('badges/name')
  Badges.new hash, url
end

.retrieve_all_tag_basedObject

Retrieves all tag-based badges in alphabetical order

Maps to ‘/badges/tags’



35
36
37
38
# File 'lib/rubyoverflow/badges.rb', line 35

def retrieve_all_tag_based
  hash, url = request('badges/tags')
  Badges.new hash, url
end

.retrieve_by_user(id) ⇒ Object

Retrieves all badges that have been awarded to a set of users by their id(s)

id can be an int, string or an array of ints or strings

Maps to ‘/users/id/badges’



45
46
47
48
49
50
# File 'lib/rubyoverflow/badges.rb', line 45

def retrieve_by_user(id)
  id = convert_to_id_list(id)

  hash, url = request('users/'+id.to_s+'/badges')
  Badges.new hash, url
end