class MediaWiktory::Wikipedia::Actions::Protect
Change the protection level of a page.
Usage:
“`ruby api.protect.title(value).perform # returns string with raw output # or api.protect.title(value).response # returns output parsed and wrapped into Response
object “`
See {Base} for generic explanation of working with MediaWiki actions and {MediaWiktory::Wikipedia::Response} for working with action responses.
All action's parameters are documented as its public methods, see below.
Public Instance Methods
@private
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 60 def _expiry(value) merge(expiry: value.to_s, replace: false) end
@private
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 47 def _protections(value) merge(protections: value.to_s, replace: false) end
@private
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 108 def _watchlist(value) defined?(super) && super || ["watch", "unwatch", "preferences", "nochange"].include?(value.to_s) && merge(watchlist: value.to_s) end
Enable cascading protection (i.e. protect transcluded templates and images used in this page). Ignored if none of the given protection levels support cascading.
@return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 88 def cascade() merge(cascade: 'true') end
Expiry timestamps. If only one timestamp is set, it'll be used for all protections. Use infinite, indefinite, infinity, or never, for a never-expiring protection.
@param values [Array<String>] @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 55 def expiry(*values) values.inject(self) { |res, val| res._expiry(val) } end
ID of the page to (un)protect. Cannot be used together with title.
@param value [Integer] @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 34 def pageid(value) merge(pageid: value.to_s) end
List of protection levels, formatted action=level (e.g. edit=sysop). A level of all means everyone is allowed to take the action, i.e. no restriction.
@param values [Array<String>] @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 42 def protections(*values) values.inject(self) { |res, val| res._protections(val) } end
Reason for (un)protecting.
@param value [String] @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 68 def reason(value) merge(reason: value.to_s) end
Title of the page to (un)protect. Cannot be used together with pageid.
@param value [String] @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 26 def title(value) merge(title: value.to_s) end
A “csrf” token retrieved from action=query&meta=tokens
@param value [String] @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 116 def token(value) merge(token: value.to_s) end
If set, add the page being (un)protected to the current user's watchlist.
@return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 95 def watch() merge(watch: 'true') end
Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.
@param value [String] One of “watch”, “unwatch”, “preferences”, “nochange”. @return [self]
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 103 def watchlist(value) _watchlist(value) or fail ArgumentError, "Unknown value for watchlist: #{value}" end