Class: Nmap::Command::PortRange Private
- 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 port range.
Constant Summary collapse
- PORT_RANGE_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.
Regular expression to validate either a port or a port range.
/(?:#{PORT_NUMBER_REGEXP})?-(?:#{PORT_NUMBER_REGEXP})?|#{PORT_REGEXP}/
- 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.
Regular expression to validate either a port or a port range.
/\A#{PORT_RANGE_REGEXP}\z/
Constants inherited from Port
Nmap::Command::Port::PORT_NUMBER_REGEXP, Nmap::Command::Port::PORT_REGEXP, Nmap::Command::Port::SERVICE_NAME_REGEXP
Instance Method Summary collapse
-
#format(value) ⇒ String
private
Formats the given port or port range value.
-
#validate(value) ⇒ true, (false, String)
private
Validates the given port or port range value.
Methods inherited from Port
Constructor Details
This class inherits a constructor from Nmap::Command::Port
Instance Method Details
#format(value) ⇒ 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.
Formats the given port or port range value.
318 319 320 321 322 323 324 325 |
# File 'lib/nmap/command.rb', line 318 def format(value) case value when Range "#{value.begin}-#{value.end}" else super(value) end end |
#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 the given port or port range value.
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/nmap/command.rb', line 282 def validate(value) case value when Range valid, = super(value.begin) unless valid return [valid, ] end valid, = super(value.end) unless valid return [valid, ] end return true when String if value =~ REGEXP return true else return [false, "must be a valid port number, port range, or service name (#{value.inspect})"] end else super(value) end end |