Class: Serel::Badge
Overview
The Badge class represents a Stack Exchange badge object.
Finding Badges
Badges can be retrieved using any of the standard finder methods: all
, get
& find
.
all
Serel::Badge.all
Unlike several of the other classes (Answer, Comment, Question etc) where the usage of all
is recommended against, all
is probably the most useful finder method for retrieving badges, since a partial set of badges is probably not useful, and only a few pages have to be retrieved each time this is called. At the time of writing this, Stack Overflow required 17 pages to be retrieved, Server Fault required 2, and Gaming required 1, and shouldn’t make too much of a dent in your quota.
find
Serel::Badge.find(id)
Retrieves a badge or badges by ID.
get
Serel::Badge.get
Retrieves a page of badge results, applying any scopes that have previously been defined.
Badge.named
Serel::Badge.named.get
See the documentation for Badge.named below.
Badge.recipients
Serel::Badge.recipients.get
Serel::Badge.recipients(1).get
Serel::Badge.recipients(1,2,3).get
See the documentation for Badge.recipients below.
Badge.tags
Serel::Badge..get
See the documentation for Badge.tags below.
Class Method Summary collapse
-
.named ⇒ Serel::Relation
Retrieves only badges that are explicitly defined.
-
.recipients(*ids) ⇒ Serel::Relation
Retrieves recently awarded badges.
-
.tags ⇒ Serel::Relation
Retrieves only badges that have been awarded due to participation in a tag.
Methods inherited from Base
#[], #[]=, #all, associations, attribute, config, #find, finder_methods, #get, #initialize, #inspect, #meth, method_missing, #network, network_wide, new_relation, request, respond_to?, #type, with_ids
Constructor Details
This class inherits a constructor from Serel::Base
Class Method Details
.named ⇒ Serel::Relation
64 65 66 |
# File 'lib/serel/badge.rb', line 64 def self.named url("badges/name") end |
.recipients(*ids) ⇒ Serel::Relation
78 79 80 81 82 83 84 85 |
# File 'lib/serel/badge.rb', line 78 def self.recipients(*ids) if ids.length > 0 arg = ids.length > 1 ? ids.join(';') : ids.pop url("badges/#{arg}/recipients") else url("badges/recipients") end end |
.tags ⇒ Serel::Relation
92 93 94 |
# File 'lib/serel/badge.rb', line 92 def self. url("badges/tags") end |