Class: Serel::Tag
Class Method Summary collapse
-
.find_by_name(name) ⇒ Serel::Tag
Finds a tag by name.
-
.moderator_only ⇒ Serel::Relation
Retrieves tags which can only be added or removed by a moderator Serel::Tag.moderator_only.get.
-
.required ⇒ Serel::Relation
Retrieves tags that are required on the site Serel::Tag.required.get.
-
.synonyms ⇒ Serel::Relation
Retrieves all the tag synonyms on the site Serel::Tag.synonyms.get.
Instance Method Summary collapse
- #faq ⇒ Object
-
#related ⇒ Serel::Relation
Retrieves related tags.
- #top_answerers(period) ⇒ Object
- #top_askers(period) ⇒ Object
- #wiki ⇒ Object
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
.find_by_name(name) ⇒ Serel::Tag
Finds a tag by name
18 19 20 |
# File 'lib/serel/tag.rb', line 18 def self.find_by_name(name) new_relation('tag', :singular).url("tags/#{CGI.escape(name)}/info").get end |
.moderator_only ⇒ Serel::Relation
Retrieves tags which can only be added or removed by a moderator Serel::Tag.moderator_only.get
This is a scoping method and can be combined with other scoping methods
27 28 29 |
# File 'lib/serel/tag.rb', line 27 def self.moderator_only url("tags/moderator-only") end |
.required ⇒ Serel::Relation
Retrieves tags that are required on the site Serel::Tag.required.get
This is a scoping method and can be combined with other scoping methods.
36 37 38 |
# File 'lib/serel/tag.rb', line 36 def self.required url("tags/required") end |
.synonyms ⇒ Serel::Relation
Retrieves all the tag synonyms on the site Serel::Tag.synonyms.get
This is a scoping method and can be combined with other scoping methods.
45 46 47 |
# File 'lib/serel/tag.rb', line 45 def self.synonyms new_relation(:tag_synonym).url("tags/synonyms") end |
Instance Method Details
#faq ⇒ Object
49 50 51 |
# File 'lib/serel/tag.rb', line 49 def faq type(:tag).url("tags/#{name}/faq") end |
#related ⇒ Serel::Relation
Retrieves related tags. Serel::Tag.find(1).related.get
This is a scoping method and can be combined with other scoping methods.
58 59 60 |
# File 'lib/serel/tag.rb', line 58 def type(:tag).url("tags/#{name}/related") end |
#top_answerers(period) ⇒ Object
62 63 64 65 |
# File 'lib/serel/tag.rb', line 62 def top_answerers(period) raise ArgumentError, 'period must be :all_time or :month' unless [:all_time, :month].include? period type(:tag_score).url("tags/#{name}/top-answerers/#{period}") end |
#top_askers(period) ⇒ Object
67 68 69 70 |
# File 'lib/serel/tag.rb', line 67 def top_askers(period) raise ArgumentError, 'period must be :all_time or :month' unless [:all_time, :month].include? period type(:tag_score).url("tags/#{name}/top-askers/#{period}") end |
#wiki ⇒ Object
72 73 74 |
# File 'lib/serel/tag.rb', line 72 def wiki type(:tag_wiki, :singular).url("tags/#{name}/wikis").get end |