class Nmap::Command::HexString

Represents a hex string.

@api private

Constants

REGEXP

Public Instance Methods

validate(value) click to toggle source

Validates a hex string value.

@param [String, to_s] value

The hex string 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 496
def validate(value)
  valid, message = super(value)

  unless valid
    return [valid, message]
  end

  value = value.to_s

  unless value =~ REGEXP
    return [false, "must be of the format 0xAABBCCDDEEFF..., AABBCCDDEEFF..., or \\xAA\\xBB\\xCC\\xDD\\xEE\\xFF..."]
  end

  return true
end