Class: Nexpose::UserAccount

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

Overview

User accounts on an asset.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(name = nil, id = 0, full_name = nil, attributes = []) ⇒ UserAccount

Returns a new instance of UserAccount.



151
152
153
# File 'lib/nexpose/asset.rb', line 151

def initialize(name = nil, id = 0, full_name = nil, attributes = [])
  @id, @name, @full_name, @attributes = id, name, full_name, attributes
end

Instance Attribute Details

#attributesObject (readonly)

Account attributes.



149
150
151
# File 'lib/nexpose/asset.rb', line 149

def attributes
  @attributes
end

#full_nameObject (readonly)

Full name of the user.



147
148
149
# File 'lib/nexpose/asset.rb', line 147

def full_name
  @full_name
end

#idObject (readonly)

Unique identifier of the user as determined by the asset (not Nexpose).



145
146
147
# File 'lib/nexpose/asset.rb', line 145

def id
  @id
end

#nameObject (readonly)

User account name.



143
144
145
# File 'lib/nexpose/asset.rb', line 143

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



162
163
164
165
166
167
168
169
170
# File 'lib/nexpose/asset.rb', line 162

def <=>(other)
  c = name <=> other.name
  return c unless c == 0
  c = id <=> other.id
  return c unless c == 0
  c = full_name <=> other.full_name
  return c unless c == 0
  attributes <=> other.attributes
end

#==(other) ⇒ Object



172
173
174
# File 'lib/nexpose/asset.rb', line 172

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/nexpose/asset.rb', line 176

def eql?(other)
  name.eql?(other.name) && id.eql?(other.id) && full_name.eql?(other.full_name) && attributes.eql?(other.attributes)
end

#to_hObject



155
156
157
158
159
160
# File 'lib/nexpose/asset.rb', line 155

def to_h
  { name: name,
    id: id,
    full_name: full_name,
    attributes: Attributes.to_hash(attributes) }
end