Class: MediaWiktory::Wikipedia::Actions::Options

Inherits:
Post
  • Object
show all
Defined in:
lib/mediawiktory/wikipedia/actions/options.rb

Overview

Change preferences of the current user.

Usage:

api.options.reset(value).perform # returns string with raw output
# or
api.options.reset(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

Methods inherited from Post

#perform

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

#change(*values) ⇒ self

List of changes, formatted name=value (e.g. skin=vector). If no value is given (not even an equals sign), e.g., optionname|otheroption|..., the option will be reset to its default value. If any value passed contains the pipe character (|), use the alternative multiple-value separator for correct operation.

Parameters:

  • values (Array<String>)

Returns:

  • (self)


46
47
48
# File 'lib/mediawiktory/wikipedia/actions/options.rb', line 46

def change(*values)
  values.inject(self) { |res, val| res._change(val) }
end

#optionname(value) ⇒ self

The name of the option that should be set to the value given by optionvalue.

Parameters:

  • value (String)

Returns:

  • (self)


59
60
61
# File 'lib/mediawiktory/wikipedia/actions/options.rb', line 59

def optionname(value)
  merge(optionname: value.to_s)
end

#optionvalue(value) ⇒ self

The value for the option specified by optionname.

Parameters:

  • value (String)

Returns:

  • (self)


67
68
69
# File 'lib/mediawiktory/wikipedia/actions/options.rb', line 67

def optionvalue(value)
  merge(optionvalue: value.to_s)
end

#resetself

Resets preferences to the site defaults.

Returns:

  • (self)


25
26
27
# File 'lib/mediawiktory/wikipedia/actions/options.rb', line 25

def reset()
  merge(reset: 'true')
end

#resetkinds(*values) ⇒ self

List of types of options to reset when the reset option is set.

Parameters:

  • values (Array<String>)

    Allowed values: "registered", "registered-multiselect", "registered-checkmatrix", "userjs", "special", "unused", "all".

Returns:

  • (self)


33
34
35
# File 'lib/mediawiktory/wikipedia/actions/options.rb', line 33

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

#token(value) ⇒ self

A "csrf" token retrieved from action=query&meta=tokens

Parameters:

  • value (String)

Returns:

  • (self)


75
76
77
# File 'lib/mediawiktory/wikipedia/actions/options.rb', line 75

def token(value)
  merge(token: value.to_s)
end