class Aspire::Object::User

Represents a user profile in the Aspire API

Attributes

email[RW]

@!attribute [rw] email

@return [Array<String>] the list of email addresses for the user
first_name[RW]

@!attribute [rw] first_name

@return [String] the user's first name
role[RW]

@!attribute [rw] role

@return [Array<String>] the Aspire roles associated with the user
surname[RW]

@!attribute [rw] surname

@return [String] the user's last name

Public Class Methods

new(uri, factory, json: nil, ld: nil) click to toggle source

Initialises a new User instance @param uri [String] the URI of the user profile @param factory [Aspire::Object::Factory] the data object factory @param json [Hash] the user profile data from the Aspire JSON API @param ld [Hash] the user profile data from the Aspire linked data API @return [void]

Calls superclass method Aspire::Object::Base::new
# File lib/aspire/object/user.rb, line 29
def initialize(uri, factory, json: nil, ld: nil)
  super(uri, factory)
  json ||= {}
  self.email = json['email']
  self.first_name = json['firstName']
  self.role = json['role']
  self.surname = json['surname']
end

Public Instance Methods

to_s() click to toggle source

Returns a string representation of the user profile (name and emails) @return [String] the string representation of the user profile

# File lib/aspire/object/user.rb, line 40
def to_s
  emails = email.nil? || email.empty? ? '' : " <#{email.join('; ')}>"
  "#{first_name} #{surname}#{emails}"
end