Class: Nmap::Port
Overview
Wraps a port XML element.
Instance Method Summary collapse
-
#initialize(node) ⇒ Port
constructor
Creates a new Port object.
-
#inspect ⇒ String
Inspects the port.
-
#number ⇒ Integer
(also: #to_i)
The port number.
-
#protocol ⇒ Symbol
The protocol the port runs on.
-
#reason ⇒ String
The reason the port was discovered.
-
#service ⇒ Service
The fingerprinted service of the port.
-
#state ⇒ Symbol
The state of the port.
-
#to_s ⇒ String
Converts the port to a String.
Methods included from Scripts
Constructor Details
#initialize(node) ⇒ Port
Creates a new Port object.
18 19 20 |
# File 'lib/nmap/port.rb', line 18 def initialize(node) @node = node end |
Instance Method Details
#inspect ⇒ String
Inspects the port.
94 95 96 |
# File 'lib/nmap/port.rb', line 94 def inspect "#<#{self.class}: #{self}>" end |
#number ⇒ Integer Also known as: to_i
The port number.
38 39 40 |
# File 'lib/nmap/port.rb', line 38 def number @number ||= @node['portid'].to_i end |
#protocol ⇒ Symbol
The protocol the port runs on
28 29 30 |
# File 'lib/nmap/port.rb', line 28 def protocol @protocol ||= @node['protocol'].to_sym end |
#reason ⇒ String
The reason the port was discovered.
58 59 60 |
# File 'lib/nmap/port.rb', line 58 def reason @reason ||= @node.at_xpath('state/@reason').inner_text end |
#service ⇒ Service
The fingerprinted service of the port.
70 71 72 73 74 |
# File 'lib/nmap/port.rb', line 70 def service @service_info ||= if (service = @node.at_xpath('service')) Service.new(service) end end |
#state ⇒ Symbol
The state of the port.
48 49 50 |
# File 'lib/nmap/port.rb', line 48 def state @state ||= @node.at_xpath('state/@state').inner_text.to_sym end |
#to_s ⇒ String
Converts the port to a String.
84 85 86 |
# File 'lib/nmap/port.rb', line 84 def to_s number.to_s end |