Class: Aspire::Object::User
Overview
Represents a user profile in the Aspire API
Constant Summary
Constants inherited from Base
Constants included from Util
Instance Attribute Summary collapse
-
#email ⇒ Array<String>
The list of email addresses for the user.
-
#first_name ⇒ String
The user’s first name.
-
#role ⇒ Array<String>
The Aspire roles associated with the user.
-
#surname ⇒ String
The user’s last name.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(uri, factory, json: nil, ld: nil) ⇒ void
constructor
Initialises a new User instance.
-
#to_s ⇒ String
Returns a string representation of the user profile (name and emails).
Methods inherited from Base
#get_boolean, #get_date, #get_property
Methods included from Util
#child_url?, #duration, #id_from_uri, #item?, #linked_data, #linked_data_path, #list?, #list_url?, #module?, #parent_url?, #parse_url, #resource?, #section?, #url_for_comparison, #url_path, #user?
Constructor Details
#initialize(uri, factory, json: nil, ld: nil) ⇒ void
Initialises a new User instance
29 30 31 32 33 34 35 36 |
# 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 |
Instance Attribute Details
#email ⇒ Array<String>
Returns the list of email addresses for the user.
9 10 11 |
# File 'lib/aspire/object/user.rb', line 9 def email @email end |
#first_name ⇒ String
Returns the user’s first name.
13 14 15 |
# File 'lib/aspire/object/user.rb', line 13 def first_name @first_name end |
#role ⇒ Array<String>
Returns the Aspire roles associated with the user.
17 18 19 |
# File 'lib/aspire/object/user.rb', line 17 def role @role end |
#surname ⇒ String
Returns the user’s last name.
21 22 23 |
# File 'lib/aspire/object/user.rb', line 21 def surname @surname end |
Instance Method Details
#to_s ⇒ String
Returns a string representation of the user profile (name and emails)
40 41 42 43 |
# File 'lib/aspire/object/user.rb', line 40 def to_s emails = email.nil? || email.empty? ? '' : " <#{email.join('; ')}>" "#{first_name} #{surname}#{emails}" end |