class Nmap::Command::Time

Represents a unit of time.

@api private

Constants

REGEXP

Regular expression for validating a unit of time.

Public Instance Methods

validate(value) click to toggle source

Validates a time value.

@param [String, Integer] value

The time value to validate.

@return [true, (false, String)]

Returns true if the value is considered valid, or false and a
validation message if the value is not valid.
Calls superclass method
# File lib/nmap/command.rb, line 455
def validate(value)
  case value
  when Integer then true
  else
    valid, message = super(value)

    unless valid
      return [valid, message]
    end

    value = value.to_s

    unless value =~ REGEXP
      return [false, "must be a number and end with 'ms', 's', 'm', or 'h'"]
    end

    return true
  end
end