Class: Nessus::Version1::Port
- Inherits:
-
Object
- Object
- Nessus::Version1::Port
- Defined in:
- lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb
Instance Attribute Summary collapse
-
#number ⇒ Boolean
readonly
Return false if the port object number is nil.
-
#protocol ⇒ Object
readonly
Port Protocol.
-
#raw_string ⇒ Object
readonly
Raw output string from nessus.
-
#service ⇒ Object
readonly
Port Service.
Class Method Summary collapse
-
.parse(str) ⇒ Object
Parse A passed port string and return a Port Object.
Instance Method Summary collapse
-
#initialize(service, number, protocol, raw_string) ⇒ Port
constructor
Creates A New Port Object Port.new(“ssh”,22,“tcp”, str).
-
#tcp? ⇒ Boolean
Return true iF port protocol Ii tcp.
-
#to_s ⇒ String
Return the port as a string.
-
#udp? ⇒ Boolean
Return true iF port protocol Ii udp.
Constructor Details
#initialize(service, number, protocol, raw_string) ⇒ Port
Creates A New Port Object Port.new(“ssh”,22,“tcp”, str)
22 23 24 25 26 27 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 22 def initialize(service,number,protocol,raw_string) @service = service @number = number @protocol = protocol @raw_string = raw_string end |
Instance Attribute Details
#number ⇒ Boolean (readonly)
Return false if the port object number is nil
9 10 11 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 9 def number @number end |
#protocol ⇒ Object (readonly)
Port Protocol
11 12 13 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 11 def protocol @protocol end |
#raw_string ⇒ Object (readonly)
Raw output string from nessus
13 14 15 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 13 def raw_string @raw_string end |
#service ⇒ Object (readonly)
Port Service
7 8 9 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 7 def service @service end |
Class Method Details
.parse(str) ⇒ Object
Parse A passed port string and return a Port Object.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 34 def Port.parse(str) begin @full_port = str components = str.match(/^([^\(]+)\((\d+)\/([^\)]+)\)/) if components return Port.new(components[1].strip, components[2].strip, components[3].strip, str) else return Port.new(false, false, false, str) end end end |
Instance Method Details
#tcp? ⇒ Boolean
Return true iF port protocol Ii tcp.
52 53 54 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 52 def tcp? @protocol == 'tcp' end |
#to_s ⇒ String
Return the port as a string.
68 69 70 71 72 73 74 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 68 def to_s if @service && @number && @protocol "#{@service} (#{@number}/#{@protocol})" else "#{@raw_string}" end end |
#udp? ⇒ Boolean
Return true iF port protocol Ii udp.
59 60 61 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb', line 59 def udp? @protocol == 'udp' end |