Module: MediaWiki::Query::Lists::Categories
- Included in:
- MediaWiki::Query::Lists
- Defined in:
- lib/mediawiki/query/lists/categories.rb
Instance Method Summary collapse
-
#get_category_members(category, type = 'page', limit = @query_limit_default) ⇒ Array<String>
Returns an array of all page titles that belong to a given category.
-
#get_files_in_category(category, limit = @query_limit_default) ⇒ Array<String>
Gets all of the files in a given category.
-
#get_subcategories(category, limit = @query_limit_default) ⇒ Array<String>
Gets the subcategories of a given category.
Instance Method Details
#get_category_members(category, type = 'page', limit = @query_limit_default) ⇒ Array<String>
Returns an array of all page titles that belong to a given category. By default, it will only get the pages. Files and subcategories can be gotten through #get_subcategories and #get_files_in_category or setting the type parameter.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mediawiki/query/lists/categories.rb', line 14 def get_category_members(category, type = 'page', limit = @query_limit_default) params = { list: 'categorymembers', cmprop: 'title', cmlimit: get_limited(limit), cmtype: type } params[:cmtitle] = category =~ /[Cc]ategory:/ ? category : "Category:#{category}" query_ary(params, 'categorymembers', 'title') end |
#get_files_in_category(category, limit = @query_limit_default) ⇒ Array<String>
Gets all of the files in a given category.
42 43 44 |
# File 'lib/mediawiki/query/lists/categories.rb', line 42 def get_files_in_category(category, limit = @query_limit_default) get_category_members(category, 'file', limit) end |
#get_subcategories(category, limit = @query_limit_default) ⇒ Array<String>
Gets the subcategories of a given category.
33 34 35 |
# File 'lib/mediawiki/query/lists/categories.rb', line 33 def get_subcategories(category, limit = @query_limit_default) get_category_members(category, 'subcat', limit) end |