Class: MediaWiktory::Wikipedia::Actions::Opensearch
- Defined in:
- lib/mediawiktory/wikipedia/actions/opensearch.rb
Overview
Search the wiki using the OpenSearch protocol.
Usage:
api.opensearch.search(value).perform # returns string with raw output
# or
api.opensearch.search(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
-
#format(value) ⇒ self
The format of the output.
-
#limit(value) ⇒ self
Maximum number of results to return.
-
#namespace(*values) ⇒ self
Namespaces to search.
-
#profile(value) ⇒ self
Search profile to use.
-
#redirects(value) ⇒ self
How to handle redirects:.
-
#search(value) ⇒ self
Search string.
-
#suggest ⇒ self
Do nothing if $wgEnableOpenSearchSuggest is false.
-
#warningsaserror ⇒ self
If warnings are raised with format=json, return an API error instead of ignoring them.
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, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang
Instance Method Details
#format(value) ⇒ self
The format of the output.
88 89 90 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 88 def format(value) _format(value) or fail ArgumentError, "Unknown value for format: #{value}" end |
#limit(value) ⇒ self
Maximum number of results to return.
47 48 49 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 47 def limit(value) merge(limit: value.to_s) end |
#namespace(*values) ⇒ self
Namespaces to search.
34 35 36 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 34 def namespace(*values) values.inject(self) { |res, val| res._namespace(val) or fail ArgumentError, "Unknown value for namespace: #{val}" } end |
#profile(value) ⇒ self
Search profile to use.
55 56 57 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 55 def profile(value) _profile(value) or fail ArgumentError, "Unknown value for profile: #{value}" end |
#redirects(value) ⇒ self
How to handle redirects:
75 76 77 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 75 def redirects(value) _redirects(value) or fail ArgumentError, "Unknown value for redirects: #{value}" end |
#search(value) ⇒ self
Search string.
26 27 28 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 26 def search(value) merge(search: value.to_s) end |
#suggest ⇒ self
Do nothing if $wgEnableOpenSearchSuggest is false.
67 68 69 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 67 def suggest() merge(suggest: 'true') end |
#warningsaserror ⇒ self
If warnings are raised with format=json, return an API error instead of ignoring them.
100 101 102 |
# File 'lib/mediawiktory/wikipedia/actions/opensearch.rb', line 100 def warningsaserror() merge(warningsaserror: 'true') end |