Class: Nmap::Command::HexString Private

Inherits:
CommandMapper::Types::Str
  • Object
show all
Defined in:
lib/nmap/command.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents a hex string.

Constant Summary collapse

REGEXP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/\A(?:(?:0x)?[0-9A-F]+|(?:\\x[0-9A-F]{2})+)\z/

Instance Method Summary collapse

Instance Method Details

#validate(value) ⇒ true, (false, String)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Validates a hex string value.

Parameters:

  • value (String, #to_s)

    The hex string value to validate.

Returns:

  • (true, (false, String))

    Returns true if the value is considered valid, or false and a validation message if the value is not valid.



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/nmap/command.rb', line 498

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