Class: Nexpose::Service

Inherits:
APIObject show all
Defined in:
lib/nexpose/asset.rb

Overview

A service endpoint on an asset.

Defined Under Namespace

Modules: Protocol

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(port = 0, protocol = Protocol::RAW, name = nil) ⇒ Service

Returns a new instance of Service.



88
89
90
# File 'lib/nexpose/asset.rb', line 88

def initialize(port = 0, protocol = Protocol::RAW, name = nil)
  @port, @protocol, @name = port, protocol, name
end

Instance Attribute Details

#nameObject (readonly)

Name of the service. [Optional]



82
83
84
# File 'lib/nexpose/asset.rb', line 82

def name
  @name
end

#portObject (readonly)

Port on which the service is running.



84
85
86
# File 'lib/nexpose/asset.rb', line 84

def port
  @port
end

#protocolObject (readonly)

Protocol used to communicate to the port. @see Service::Protocol.



86
87
88
# File 'lib/nexpose/asset.rb', line 86

def protocol
  @protocol
end

Instance Method Details

#<=>(other) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/nexpose/asset.rb', line 98

def <=>(other)
  c = port <=> other.port
  return c unless c.zero?
  c = protocol <=> other.protocol
  return c unless c.zero?
  name <=> other.name
end

#==(other) ⇒ Object



106
107
108
# File 'lib/nexpose/asset.rb', line 106

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/nexpose/asset.rb', line 110

def eql?(other)
  port.eql?(other.port) && protocol.eql?(other.protocol) && name.eql?(other.name)
end

#to_hObject



92
93
94
95
96
# File 'lib/nexpose/asset.rb', line 92

def to_h
  { name: name,
    port: port,
    protocol: protocol }
end