Class: Wpxf::PortOption
- 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
-
#normalize(value) ⇒ Integer
A normalized value to conform with the type that the option is conveying.
-
#valid?(value) ⇒ Boolean
Check if the specified value is valid in the context of this option.
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.
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.
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 |