class Ncrack::XML::Port
Represents a ‘port` XML
element.
Constants
- PROTOCOLS
Mapping of the ‘protocol` attribute values to Symbols.
Public Class Methods
new(node)
click to toggle source
Initializes the port object.
@param [Nokogiri::XML::Node] node
The XML node for the `port` XML element.
@api private
# File lib/ncrack/xml/port.rb, line 16 def initialize(node) @node = node end
Public Instance Methods
name()
click to toggle source
The name associated with the port.
@return [String]
The value of the `name` attribute.
# File lib/ncrack/xml/port.rb, line 56 def name @name ||= @node['name'] end
number()
click to toggle source
The port number.
@return [Integer]
The parsed value of the `portid` attribute.
# File lib/ncrack/xml/port.rb, line 46 def number @number ||= @node['portid'].to_i end
protocol()
click to toggle source
The protocol of the port.
@return [:tcp, :udp, String]
The value of the `protocol` attribute.
# File lib/ncrack/xml/port.rb, line 32 def protocol @protocl ||= ( protocol = @node['protocol'] PROTOCOLS.fetch(protocol,protocol) ) end
to_i()
click to toggle source
Converts the port to an Integer.
@return [Integer]
Returns the {#number}.
# File lib/ncrack/xml/port.rb, line 66 def to_i number.to_i end
to_s()
click to toggle source
Converts the port to a String.
@return [String]
Returns the {#name}.
# File lib/ncrack/xml/port.rb, line 76 def to_s name.to_s end