Class: Nmap::XML::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.
-
#reason_ttl ⇒ Integer
The reason TTL.
-
#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.
21 22 23 |
# File 'lib/nmap/xml/port.rb', line 21 def initialize(node) @node = node end |
Instance Method Details
#inspect ⇒ String
Inspects the port.
108 109 110 |
# File 'lib/nmap/xml/port.rb', line 108 def inspect "#<#{self.class}: #{self}>" end |
#number ⇒ Integer Also known as: to_i
The port number.
41 42 43 |
# File 'lib/nmap/xml/port.rb', line 41 def number @number ||= @node['portid'].to_i end |
#protocol ⇒ Symbol
The protocol the port runs on
31 32 33 |
# File 'lib/nmap/xml/port.rb', line 31 def protocol @protocol ||= @node['protocol'].to_sym end |
#reason ⇒ String
The reason the port was discovered.
61 62 63 |
# File 'lib/nmap/xml/port.rb', line 61 def reason @reason ||= @node.at_xpath('state/@reason').inner_text end |
#reason_ttl ⇒ Integer
The reason TTL.
72 73 74 |
# File 'lib/nmap/xml/port.rb', line 72 def reason_ttl @reason ||= @node.at_xpath('state/@reason_ttl').inner_text.to_i end |
#service ⇒ Service
The fingerprinted service of the port.
84 85 86 87 88 |
# File 'lib/nmap/xml/port.rb', line 84 def service @service_info ||= if (service = @node.at_xpath('service')) Service.new(service) end end |
#state ⇒ Symbol
The state of the port.
51 52 53 |
# File 'lib/nmap/xml/port.rb', line 51 def state @state ||= @node.at_xpath('state/@state').inner_text.to_sym end |
#to_s ⇒ String
Converts the port to a String.
98 99 100 |
# File 'lib/nmap/xml/port.rb', line 98 def to_s number.to_s end |