Class: Wpxf::PortOption

Inherits:
Option
  • Object
show all
Defined in:
lib/wpxf/core/opts/port_option.rb

Overview

A network port option.

Instance Attribute Summary

Attributes inherited from Option

#advanced, #default, #desc, #enums, #evasion, #name, #regex, #required

Instance Method Summary collapse

Methods inherited from Option

#advanced?, #display_value, #empty?, #empty_required_value?, #evasion?, #initialize, #required?, #update_optional_attributes, #value?

Constructor Details

This class inherits a constructor from Wpxf::Option

Instance Method Details

#normalize(value) ⇒ Integer

Returns a normalized value to conform with the type that the option is conveying.

Parameters:

  • value

    the value to normalize.

Returns:

  • (Integer)

    a normalized value to conform with the type that the option is conveying.



10
11
12
# File 'lib/wpxf/core/opts/port_option.rb', line 10

def normalize(value)
  value.to_i
end

#valid?(value) ⇒ Boolean

Check if the specified value is valid in the context of this option.

Parameters:

  • value

    the value to validate.

Returns:

  • (Boolean)

    true if valid.



17
18
19
20
21
22
23
# File 'lib/wpxf/core/opts/port_option.rb', line 17

def valid?(value)
  if value.to_s.match(/^\d+$/).nil? || (value.to_i.negative? || value.to_i > 65_535)
    return false
  end

  super
end