Module: MediaWiktory::Wikipedia::Modules::Categorymembers

Defined in:
lib/mediawiktory/wikipedia/modules/categorymembers.rb

Overview

List all pages in a given category.

The "submodule" (MediaWiki API term) is included in action after setting some param, providing additional tweaking for this param. Example (for Actions::Query and its submodules):

api.query             # returns Actions::Query
   .prop(:revisions)  # adds prop=revisions to action URL, and includes Modules::Revisions into action
   .limit(10)         # method of Modules::Revisions, adds rvlimit=10 to URL

All submodule's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Instance Method Details

#continue(value) ⇒ self

When more results are available, use this to continue.

Parameters:

  • value (String)

Returns:

  • (self)


80
81
82
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 80

def continue(value)
  merge(cmcontinue: value.to_s)
end

#dir(value) ⇒ self

In which direction to sort.

Parameters:

  • value (String)

    One of "asc", "desc", "ascending", "descending", "newer", "older".

Returns:

  • (self)


109
110
111
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 109

def dir(value)
  _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}"
end

#end(value) ⇒ self

Timestamp to end listing at. Can only be used with cmsort=timestamp.

Parameters:

  • value (Time)

Returns:

  • (self)


130
131
132
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 130

def end(value)
  merge(cmend: value.iso8601)
end

#endhexsortkey(value) ⇒ self

Sortkey to end listing at, as returned by cmprop=sortkey. Can only be used with cmsort=sortkey.

Parameters:

  • value (String)

Returns:

  • (self)


146
147
148
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 146

def endhexsortkey(value)
  merge(cmendhexsortkey: value.to_s)
end

#endsortkey(value) ⇒ self

Use cmendhexsortkey instead.

Parameters:

  • value (String)

Returns:

  • (self)


178
179
180
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 178

def endsortkey(value)
  merge(cmendsortkey: value.to_s)
end

#endsortkeyprefix(value) ⇒ self

Sortkey prefix to end listing before (not at; if this value occurs it will not be included!). Can only be used with cmsort=sortkey. Overrides cmendhexsortkey.

Parameters:

  • value (String)

Returns:

  • (self)


162
163
164
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 162

def endsortkeyprefix(value)
  merge(cmendsortkeyprefix: value.to_s)
end

#limit(value) ⇒ self

The maximum number of pages to return.

Parameters:

  • value (Integer, "max")

Returns:

  • (self)


88
89
90
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 88

def limit(value)
  merge(cmlimit: value.to_s)
end

#namespace(*values) ⇒ self

Only include pages in these namespaces. Note that cmtype=subcat or cmtype=file may be used instead of cmnamespace=14 or 6.

Parameters:

  • values (Array<String>)

    Allowed values: "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "100", "101", "108", "109", "118", "119", "446", "447", "710", "711", "828", "829", "2300", "2301", "2302", "2303".

Returns:

  • (self)


54
55
56
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 54

def namespace(*values)
  values.inject(self) { |res, val| res._namespace(val) or fail ArgumentError, "Unknown value for namespace: #{val}" }
end

#pageid(value) ⇒ self

Page ID of the category to enumerate. Cannot be used together with cmtitle.

Parameters:

  • value (Integer)

Returns:

  • (self)


33
34
35
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 33

def pageid(value)
  merge(cmpageid: value.to_s)
end

#prop(*values) ⇒ self

Which pieces of information to include:

Parameters:

  • values (Array<String>)

    Allowed values: "ids" (Adds the page ID), "title" (Adds the title and namespace ID of the page), "sortkey" (Adds the sortkey used for sorting in the category (hexadecimal string)), "sortkeyprefix" (Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)), "type" (Adds the type that the page has been categorised as (page, subcat or file)), "timestamp" (Adds the timestamp of when the page was included).

Returns:

  • (self)


41
42
43
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 41

def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end

#sort(value) ⇒ self

Property to sort by.

Parameters:

  • value (String)

    One of "sortkey", "timestamp".

Returns:

  • (self)


96
97
98
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 96

def sort(value)
  _sort(value) or fail ArgumentError, "Unknown value for sort: #{value}"
end

#start(value) ⇒ self

Timestamp to start listing from. Can only be used with cmsort=timestamp.

Parameters:

  • value (Time)

Returns:

  • (self)


122
123
124
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 122

def start(value)
  merge(cmstart: value.iso8601)
end

#starthexsortkey(value) ⇒ self

Sortkey to start listing from, as returned by cmprop=sortkey. Can only be used with cmsort=sortkey.

Parameters:

  • value (String)

Returns:

  • (self)


138
139
140
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 138

def starthexsortkey(value)
  merge(cmstarthexsortkey: value.to_s)
end

#startsortkey(value) ⇒ self

Use cmstarthexsortkey instead.

Parameters:

  • value (String)

Returns:

  • (self)


170
171
172
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 170

def startsortkey(value)
  merge(cmstartsortkey: value.to_s)
end

#startsortkeyprefix(value) ⇒ self

Sortkey prefix to start listing from. Can only be used with cmsort=sortkey. Overrides cmstarthexsortkey.

Parameters:

  • value (String)

Returns:

  • (self)


154
155
156
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 154

def startsortkeyprefix(value)
  merge(cmstartsortkeyprefix: value.to_s)
end

#title(value) ⇒ self

Which category to enumerate (required). Must include the Category: prefix. Cannot be used together with cmpageid.

Parameters:

  • value (String)

Returns:

  • (self)


25
26
27
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 25

def title(value)
  merge(cmtitle: value.to_s)
end

#type(*values) ⇒ self

Which type of category members to include. Ignored when cmsort=timestamp is set.

Parameters:

  • values (Array<String>)

    Allowed values: "page", "subcat", "file".

Returns:

  • (self)


67
68
69
# File 'lib/mediawiktory/wikipedia/modules/categorymembers.rb', line 67

def type(*values)
  values.inject(self) { |res, val| res._type(val) or fail ArgumentError, "Unknown value for type: #{val}" }
end