Module: MediaWiki::Query::Lists::Miscellaneous

Included in:
MediaWiki::Query::Lists
Defined in:
lib/mediawiki/query/lists/miscellaneous.rb

Instance Method Summary collapse

Instance Method Details

#get_random_pages(limit = 1, namespace = 0) ⇒ Array<String>

Returns an array of random pages titles.

Parameters:

  • limit (Fixnum) (defaults to: 1)

    The number of articles to get. Defaults to 1. Cannot be greater than 10 for normal users, or 20 for bots. This method does not use the query_limit_default attribute. This method does not use continuation.

  • namespace (Fixnum) (defaults to: 0)

    The namespace ID. Defaults to 0 (the main namespace).

Returns:

  • (Array<String>)

    All members

See Also:

Since:

  • 0.2.0



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mediawiki/query/lists/miscellaneous.rb', line 13

def get_random_pages(limit = 1, namespace = 0)
  params = {
    list: 'random',
    rnlimit: get_limited(limit, 10, 20),
    rnnamespace: validate_namespace(namespace)
  }

  continue = @use_continuation
  @use_continuation = false
  ret = query_ary(params, 'random', 'title')
  @use_continuation = continue
  ret
end

#get_tags(limit = @query_limit_default) ⇒ Array<String>

Gets the valid change tags on the wiki.

Parameters:

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of results to get. Maximum 5000 for bots and 500 for users.

Returns:

  • (Array<String>)

    All tag names.

See Also:

Since:

  • 0.10.0



32
33
34
35
36
37
38
39
# File 'lib/mediawiki/query/lists/miscellaneous.rb', line 32

def get_tags(limit = @query_limit_default)
  params = {
    list: 'tags',
    tglimit: get_limited(limit)
  }

  query_ary(params, 'tags', 'name')
end