class Nmap::XML::Port
Wraps a ‘port` XML
element.
@since 1.0.0
Public Class Methods
new(node)
click to toggle source
Creates a new Port
object.
@param [Nokogiri::XML::Element] node
The XML `port` element.
# File lib/nmap/xml/port.rb, line 21 def initialize(node) @node = node end
Public Instance Methods
inspect()
click to toggle source
Inspects the port.
@return [String]
The inspected port.
# File lib/nmap/xml/port.rb, line 108 def inspect "#<#{self.class}: #{self}>" end
number()
click to toggle source
The port number.
@return [Integer]
The number of the port.
# File lib/nmap/xml/port.rb, line 41 def number @number ||= @node['portid'].to_i end
Also aliased as: to_i
protocol()
click to toggle source
The protocol the port runs on
@return [Symbol]
The protocol of the port.
# File lib/nmap/xml/port.rb, line 31 def protocol @protocol ||= @node['protocol'].to_sym end
reason()
click to toggle source
The reason the port was discovered.
@return [String]
How the port was discovered.
# File lib/nmap/xml/port.rb, line 61 def reason @reason ||= @node.at_xpath('state/@reason').inner_text end
reason_ttl()
click to toggle source
The reason TTL.
@return [Integer]
@since 0.10.0
# File lib/nmap/xml/port.rb, line 72 def reason_ttl @reason ||= @node.at_xpath('state/@reason_ttl').inner_text.to_i end
service()
click to toggle source
The fingerprinted service of the port.
@return [Service]
The service detected on the port.
@since 0.6.0
# File lib/nmap/xml/port.rb, line 84 def service @service_info ||= if (service = @node.at_xpath('service')) Service.new(service) end end
state()
click to toggle source
The state of the port.
@return [Symbol]
The state of the port (`:open`, `:filtered` or `:closed`).
# File lib/nmap/xml/port.rb, line 51 def state @state ||= @node.at_xpath('state/@state').inner_text.to_sym end
to_s()
click to toggle source
Converts the port to a String.
@return [String]
The port number.
# File lib/nmap/xml/port.rb, line 98 def to_s number.to_s end