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.



153
154
155
# File 'lib/nexpose/asset.rb', line 153

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.



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

def attributes
  @attributes
end

#full_nameObject (readonly)

Full name of the user.



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

def full_name
  @full_name
end

#idObject (readonly)

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



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

def id
  @id
end

#nameObject (readonly)

User account name.



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

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#==(other) ⇒ Object



174
175
176
# File 'lib/nexpose/asset.rb', line 174

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/nexpose/asset.rb', line 178

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

#to_hObject



157
158
159
160
161
162
# File 'lib/nexpose/asset.rb', line 157

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