class Nmap::Port

Wraps a `port` XML element.

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/port.rb, line 18
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/port.rb, line 94
def inspect
  "#<#{self.class}: #{self}>"
end
number() click to toggle source

The port number.

@return [Integer]

The number of the port.
# File lib/nmap/port.rb, line 38
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/port.rb, line 28
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/port.rb, line 58
def reason
  @reason ||= @node.at_xpath('state/@reason').inner_text
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/port.rb, line 70
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/port.rb, line 48
def state
  @state ||= @node.at_xpath('state/@state').inner_text.to_sym
end
to_i()
Alias for: number
to_s() click to toggle source

Converts the port to a String.

@return [String]

The port number.
# File lib/nmap/port.rb, line 84
def to_s
  number.to_s
end