Class: Rubyoverflow::Badges
- Defined in:
- lib/rubyoverflow/badges.rb
Instance Attribute Summary collapse
-
#badges ⇒ Object
readonly
Returns the value of attribute badges.
Attributes inherited from PagedBase
#page, #pagesize, #query_parameters, #request_path, #total
Class Method Summary collapse
-
.retrieve_all ⇒ Object
Retrieves all badges in alphabetical order.
-
.retrieve_all_non_tag_based ⇒ Object
Retrieves all standard, non-tag-based badges in alphabetical order.
-
.retrieve_all_tag_based ⇒ Object
Retrieves all tag-based badges in alphabetical order.
-
.retrieve_by_user(id) ⇒ Object
Retrieves all badges that have been awarded to a set of users by their id(s).
Instance Method Summary collapse
-
#initialize(hash, request_path = '') ⇒ Badges
constructor
A new instance of Badges.
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
#badges ⇒ Object (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_all ⇒ Object
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_based ⇒ Object
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_based ⇒ Object
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 |