Class: Category
- Inherits:
-
Object
- Object
- Category
- Defined in:
- lib/rbmediawiki/category.rb
Overview
This class represents a category and performs actions dealing with categories.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#get_members(cmlimit = 500) ⇒ Object
get pages in the category as an array of Page elements returns false if there aren’t any, and raises NoPage if page doesn’t exist.
-
#initialize(title = nil, site = nil, id = nil) ⇒ Category
constructor
A new instance of Category.
Constructor Details
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/rbmediawiki/category.rb', line 5 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/rbmediawiki/category.rb', line 4 def title @title end |
Instance Method Details
#get_members(cmlimit = 500) ⇒ Object
get pages in the category as an array of Page elements returns false if there aren’t any, and raises NoPage if page doesn’t exist
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rbmediawiki/category.rb', line 14 def get_members(cmlimit = 500) cmcontinue = nil cms = Array.new loop { result = @site.query_list_categorymembers(@title, @title, nil, nil, cmcontinue, cmlimit) if result.key?('error') || !result['query']['categorymembers'].has_key?('cm') raise NoPage.new(), "Page [[#{@title}]] does not exist" end if result['query']['categorymembers']['cm'].is_a? Array cms = cms + result['query']['categorymembers']['cm'] else cms.push(result['query']['categorymembers']['cm']) end if result.key?('query-continue') cmcontinue = result['query-continue']['categorymembers']['cmcontinue'] else break end } return cms end |