Sha256: 74ccdf9f34e4d4d1d00d553617c61fca167b0fadf3d5c9978007307f45ff6329

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module MediaWiktory::Wikipedia
  module Actions
    # Validate an article title, filename, or username against the TitleBlacklist.
    #
    # Usage:
    #
    # ```ruby
    # api.titleblacklist.title(value).perform # returns string with raw output
    # # or
    # api.titleblacklist.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.
    #
    class Titleblacklist < MediaWiktory::Wikipedia::Actions::Get

      # The string to validate against the blacklist.
      #
      # @param value [String]
      # @return [self]
      def title(value)
        merge(tbtitle: value.to_s)
      end

      # The action to be checked.
      #
      # @param value [String] One of "create", "edit", "upload", "createtalk", "createpage", "move", "new-account".
      # @return [self]
      def action(value)
        _action(value) or fail ArgumentError, "Unknown value for action: #{value}"
      end

      # @private
      def _action(value)
        defined?(super) && super || ["create", "edit", "upload", "createtalk", "createpage", "move", "new-account"].include?(value.to_s) && merge(tbaction: value.to_s)
      end

      # Don't try to override the titleblacklist.
      #
      # @return [self]
      def nooverride()
        merge(tbnooverride: 'true')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mediawiktory-0.1.3 lib/mediawiktory/wikipedia/actions/titleblacklist.rb
mediawiktory-0.1.2 lib/mediawiktory/wikipedia/actions/titleblacklist.rb
mediawiktory-0.1.1 lib/mediawiktory/wikipedia/actions/titleblacklist.rb
mediawiktory-0.1.0 lib/mediawiktory/wikipedia/actions/titleblacklist.rb