Module: MediaWiktory::Wikipedia::Modules::Extlinks

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

Overview

Returns all external URLs (not interwikis) from the given pages.

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

#expandurlself

Expand protocol-relative URLs with the canonical protocol.

Returns:

  • (self)


61
62
63
# File 'lib/mediawiktory/wikipedia/modules/extlinks.rb', line 61

def expandurl()
  merge(elexpandurl: 'true')
end

#limit(value) ⇒ self

How many links to return.

Parameters:

  • value (Integer, "max")

Returns:

  • (self)


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

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

#offset(value) ⇒ self

When more results are available, use this to continue.

Parameters:

  • value (Integer)

Returns:

  • (self)


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

def offset(value)
  merge(eloffset: value.to_s)
end

#protocol(value) ⇒ self

Protocol of the URL. If empty and elquery is set, the protocol is http. Leave both this and elquery empty to list all external links.

Parameters:

  • value (String)

    One of "bitcoin", "ftp", "ftps", "geo", "git", "gopher", "http", "https", "irc", "ircs", "magnet", "mailto", "mms", "news", "nntp", "redis", "sftp", "sip", "sips", "sms", "ssh", "svn", "tel", "telnet", "urn", "worldwind", "xmpp".

Returns:

  • (self)


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

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

#query(value) ⇒ self

Search string without protocol. Useful for checking whether a certain page contains a certain external url.

Parameters:

  • value (String)

Returns:

  • (self)


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

def query(value)
  merge(elquery: value.to_s)
end