Module: MediaWiktory::Wikipedia::Modules::Gadgets

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

Overview

Returns a list of gadgets used on this wiki.

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

#allowedonlyself

List only gadgets allowed to current user.

Returns:

  • (self)


63
64
65
# File 'lib/mediawiktory/wikipedia/modules/gadgets.rb', line 63

def allowedonly()
  merge(gaallowedonly: 'true')
end

#categories(*values) ⇒ self

Gadgets from what categories to retrieve.

Parameters:

  • values (Array<String>)

Returns:

  • (self)


38
39
40
# File 'lib/mediawiktory/wikipedia/modules/gadgets.rb', line 38

def categories(*values)
  values.inject(self) { |res, val| res._categories(val) }
end

#enabledonlyself

List only gadgets enabled by current user.

Returns:

  • (self)


70
71
72
# File 'lib/mediawiktory/wikipedia/modules/gadgets.rb', line 70

def enabledonly()
  merge(gaenabledonly: 'true')
end

#ids(*values) ⇒ self

IDs of gadgets to retrieve.

Parameters:

  • values (Array<String>)

Returns:

  • (self)


51
52
53
# File 'lib/mediawiktory/wikipedia/modules/gadgets.rb', line 51

def ids(*values)
  values.inject(self) { |res, val| res._ids(val) }
end

#prop(*values) ⇒ self

What gadget information to get:

Parameters:

  • values (Array<String>)

    Allowed values: "id" (Internal gadget ID), "metadata" (The gadget metadata), "desc" (Gadget description transformed into HTML (can be slow, use only if really needed)).

Returns:

  • (self)


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

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