Sha256: 1baf15b505b09b1100e4b9ce4529f0fad0b64a8151f64f623e582016db541821

Contents?: true

Size: 772 Bytes

Versions: 4

Compression:

Stored size: 772 Bytes

Contents

module CLIUtils
  # The generic base class for a Pref
  # Validator.
  class PrefValidator
    include Messaging

    # Holds whether the validator returned
    # successful or not.
    # @return [Boolean]
    attr_accessor :is_valid

    # Holds the message to display to the
    # user when the Validator fails.
    # @return [String]
    attr_accessor :message

    # Holds a reference to the Pref that is
    # applying this Validator.
    # @return [Pref]
    attr_accessor :pref

    # Validate the Validator!
    # @parameter [String] text
    # @raise [StandardError] if the subclass
    #   doesn't implement this method.
    # @return [void]
    def validate(text = nil)
      fail "`validate` method not implemented on caller: #{ self.class }"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cliutils-2.0.3 lib/cliutils/prefs/pref_validators/pref_validator.rb
cliutils-2.0.2 lib/cliutils/prefs/pref_validators/pref_validator.rb
cliutils-2.0.1 lib/cliutils/prefs/pref_validators/pref_validator.rb
cliutils-2.0.0 lib/cliutils/prefs/pref_validators/pref_validator.rb