Module: MediaWiktory::Wikipedia::Modules::Blocks

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

Overview

List all blocked users and IP addresses.

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

#continue(value) ⇒ self

When more results are available, use this to continue.

Parameters:

  • value (String)

Returns:

  • (self)


122
123
124
# File 'lib/mediawiktory/wikipedia/modules/blocks.rb', line 122

def continue(value)
  merge(bkcontinue: value.to_s)
end

#dir(value) ⇒ self

In which direction to enumerate:

Parameters:

  • value (String)

    One of "newer" (List oldest first. Note: bkstart has to be before bkend), "older" (List newest first (default). Note: bkstart has to be later than bkend).

Returns:

  • (self)


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

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

#end(value) ⇒ self

The timestamp to stop enumerating at.

Parameters:

  • value (Time)

Returns:

  • (self)


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

def end(value)
  merge(bkend: value.iso8601)
end

#ids(*values) ⇒ self

List of block IDs to list (optional).

Parameters:

  • values (Array<Integer>)

Returns:

  • (self)


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

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

#ip(value) ⇒ self

Get all blocks applying to this IP address or CIDR range, including range blocks. Cannot be used together with bkusers. CIDR ranges broader than IPv4/16 or IPv6/19 are not accepted.

Parameters:

  • value (String)

Returns:

  • (self)


80
81
82
# File 'lib/mediawiktory/wikipedia/modules/blocks.rb', line 80

def ip(value)
  merge(bkip: value.to_s)
end

#limit(value) ⇒ self

The maximum number of blocks to list.

Parameters:

  • value (Integer, "max")

Returns:

  • (self)


88
89
90
# File 'lib/mediawiktory/wikipedia/modules/blocks.rb', line 88

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

#prop(*values) ⇒ self

Which properties to get:

Parameters:

  • values (Array<String>)

    Allowed values: "id" (Adds the ID of the block), "user" (Adds the username of the blocked user), "userid" (Adds the user ID of the blocked user), "by" (Adds the username of the blocking user), "byid" (Adds the user ID of the blocking user), "timestamp" (Adds the timestamp of when the block was given), "expiry" (Adds the timestamp of when the block expires), "reason" (Adds the reason given for the block), "range" (Adds the range of IP addresses affected by the block), "flags" (Tags the ban with (autoblock, anononly, etc.)).

Returns:

  • (self)


96
97
98
# File 'lib/mediawiktory/wikipedia/modules/blocks.rb', line 96

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

#show(*values) ⇒ self

Show only items that meet these criteria. For example, to see only indefinite blocks on IP addresses, set bkshow=ip|!temp.

Parameters:

  • values (Array<String>)

    Allowed values: "account", "!account", "temp", "!temp", "ip", "!ip", "range", "!range".

Returns:

  • (self)


109
110
111
# File 'lib/mediawiktory/wikipedia/modules/blocks.rb', line 109

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

#start(value) ⇒ self

The timestamp to start enumerating from.

Parameters:

  • value (Time)

Returns:

  • (self)


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

def start(value)
  merge(bkstart: value.iso8601)
end

#users(*values) ⇒ self

List of users to search for (optional).

Parameters:

  • values (Array<String>)

Returns:

  • (self)


67
68
69
# File 'lib/mediawiktory/wikipedia/modules/blocks.rb', line 67

def users(*values)
  values.inject(self) { |res, val| res._users(val) }
end