Class: Ncrack::XML::Port
- Inherits:
-
Object
- Object
- Ncrack::XML::Port
- Defined in:
- lib/ncrack/xml/port.rb
Overview
Represents a port
XML element.
Constant Summary collapse
- PROTOCOLS =
Mapping of the
protocol
attribute values to Symbols. { 'tcp' => :tcp, 'udp' => :udp }
Instance Method Summary collapse
-
#initialize(node) ⇒ Port
constructor
private
Initializes the port object.
-
#name ⇒ String
The name associated with the port.
-
#number ⇒ Integer
The port number.
-
#protocol ⇒ :tcp, ...
The protocol of the port.
-
#to_i ⇒ Integer
Converts the port to an Integer.
-
#to_s ⇒ String
Converts the port to a String.
Constructor Details
#initialize(node) ⇒ Port
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the port object.
16 17 18 |
# File 'lib/ncrack/xml/port.rb', line 16 def initialize(node) @node = node end |
Instance Method Details
#name ⇒ String
The name associated with the port.
56 57 58 |
# File 'lib/ncrack/xml/port.rb', line 56 def name @name ||= @node['name'] end |
#number ⇒ Integer
The port number.
46 47 48 |
# File 'lib/ncrack/xml/port.rb', line 46 def number @number ||= @node['portid'].to_i end |
#protocol ⇒ :tcp, ...
The protocol of the port.
32 33 34 35 36 37 38 |
# File 'lib/ncrack/xml/port.rb', line 32 def protocol @protocl ||= ( protocol = @node['protocol'] PROTOCOLS.fetch(protocol,protocol) ) end |
#to_i ⇒ Integer
Converts the port to an Integer.
66 67 68 |
# File 'lib/ncrack/xml/port.rb', line 66 def to_i number.to_i end |
#to_s ⇒ String
Converts the port to a String.
76 77 78 |
# File 'lib/ncrack/xml/port.rb', line 76 def to_s name.to_s end |