Class: MediaWiktory::Wikipedia::Actions::Query
- Defined in:
- lib/mediawiktory/wikipedia/actions/query.rb
Overview
Fetch data from and about MediaWiki.
Usage:
api.query.prop(value).perform # returns string with raw output
# or
api.query.prop(value).response # returns output parsed and wrapped into Response object
See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.
All action's parameters are documented as its public methods, see below.
Instance Method Summary collapse
-
#continue(value) ⇒ self
When more results are available, use this to continue.
-
#converttitles ⇒ self
Convert titles to other variants if necessary.
-
#export ⇒ self
Export the current revisions of all given or generated pages.
-
#exportnowrap ⇒ self
Return the export XML without wrapping it in an XML result (same format as Special:Export).
-
#generator(value) ⇒ self
Get the list of pages to work on by executing the specified query module.
-
#indexpageids ⇒ self
Include an additional pageids section listing all returned page IDs.
-
#iwurl ⇒ self
Whether to get the full URL if the title is an interwiki link.
-
#list(*values) ⇒ self
Which lists to get.
-
#meta(*values) ⇒ self
Which metadata to get.
-
#pageids(*values) ⇒ self
A list of page IDs to work on.
-
#prop(*values) ⇒ self
Which properties to get for the queried pages.
-
#rawcontinue ⇒ self
Return raw query-continue data for continuation.
-
#redirects ⇒ self
Automatically resolve redirects in titles, pageids, and revids, and in pages returned by generator.
-
#revids(*values) ⇒ self
A list of revision IDs to work on.
-
#titles(*values) ⇒ self
A list of titles to work on.
Methods inherited from Get
Methods inherited from Base
#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url
Methods included from GlobalParams
#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang
Instance Method Details
#continue(value) ⇒ self
When more results are available, use this to continue.
203 204 205 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 203 def continue(value) merge(continue: value.to_s) end |
#converttitles ⇒ self
Convert titles to other variants if necessary. Only works if the wiki's content language supports variant conversion. Languages that support variant conversion include gan, iu, kk, ku, shi, sr, tg, uz and zh.
320 321 322 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 320 def converttitles() merge(converttitles: 'true') end |
#export ⇒ self
Export the current revisions of all given or generated pages.
181 182 183 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 181 def export() merge(export: 'true') end |
#exportnowrap ⇒ self
Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export.
188 189 190 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 188 def exportnowrap() merge(exportnowrap: 'true') end |
#generator(value) ⇒ self
Get the list of pages to work on by executing the specified query module.
301 302 303 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 301 def generator(value) _generator(value) or fail ArgumentError, "Unknown value for generator: #{value}" end |
#indexpageids ⇒ self
Include an additional pageids section listing all returned page IDs.
174 175 176 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 174 def indexpageids() merge(indexpageids: 'true') end |
#iwurl ⇒ self
Whether to get the full URL if the title is an interwiki link.
195 196 197 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 195 def iwurl() merge(iwurl: 'true') end |
#list(*values) ⇒ self
Which lists to get.
134 135 136 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 134 def list(*values) values.inject(self) { |res, val| res._list(val) or fail ArgumentError, "Unknown value for list: #{val}" } end |
#meta(*values) ⇒ self
Which metadata to get.
162 163 164 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 162 def (*values) values.inject(self) { |res, val| res.(val) or fail ArgumentError, "Unknown value for meta: #{val}" } end |
#pageids(*values) ⇒ self
A list of page IDs to work on.
231 232 233 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 231 def pageids(*values) values.inject(self) { |res, val| res._pageids(val) } end |
#prop(*values) ⇒ self
Which properties to get for the queried pages.
59 60 61 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 59 def prop(*values) values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } end |
#rawcontinue ⇒ self
Return raw query-continue data for continuation.
210 211 212 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 210 def rawcontinue() merge(rawcontinue: 'true') end |
#redirects ⇒ self
Automatically resolve redirects in titles, pageids, and revids, and in pages returned by generator.
313 314 315 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 313 def redirects() merge(redirects: 'true') end |
#revids(*values) ⇒ self
A list of revision IDs to work on.
244 245 246 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 244 def revids(*values) values.inject(self) { |res, val| res._revids(val) } end |
#titles(*values) ⇒ self
A list of titles to work on.
218 219 220 |
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 218 def titles(*values) values.inject(self) { |res, val| res._titles(val) } end |