Class: Nmap::Command::PortRange Private
- Defined in:
- lib/nmap/command.rb
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.
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.
/(?:#{PORT_REGEXP}|#{PORT_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.
/\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 value.
-
#validate(value) ⇒ true, (false, String)
private
Validates the given 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 value.
299 300 301 302 303 304 305 306 |
# File 'lib/nmap/command.rb', line 299 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 value.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/nmap/command.rb', line 265 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 unless value =~ REGEXP return [false, "not a valid port range (#{value.inspect})"] end return true else super(value) end end |