Class: LUSI::API::Person::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/lusi_api/person/student.rb

Overview

Represents a student’s relationship with a member of staff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, staff_relationship: nil, user_contact: nil) ⇒ Relationship

Initialises a new Relationship instance

Parameters:

  • xml (Nokogiri::XML::Document, Nokogiri::XML::Node) (defaults to: nil)

    the parsed XML root of the relationship

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • staff_relationship (LUSI::API::Core::Code, nil) (defaults to: nil)

    the default staff relationship code

  • user_contact (LUSI::API::Person::UserContact, nil) (defaults to: nil)

    the default related person’s contact details



239
240
241
242
243
# File 'lib/lusi_api/person/student.rb', line 239

def initialize(xml = nil, lookup = nil, staff_relationship: nil, user_contact: nil)
  @staff_relationship = LUSI::API::Core::Code.new(
      LUSI::API::Core::XML.xml_at(xml, 'xmlns:StaffRelationship', staff_relationship), lookup)
  @user_contact = UserContact.new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:UserContact', user_contact), lookup)
end

Instance Attribute Details

#staff_relationshipLUSI::API::Core::Code?

Returns the staff relationship type.

Returns:



228
229
230
# File 'lib/lusi_api/person/student.rb', line 228

def staff_relationship
  @staff_relationship
end

#user_contactLUSI::API::Person::UserContact?

Returns the related person’s contact details.

Returns:



232
233
234
# File 'lib/lusi_api/person/student.rb', line 232

def user_contact
  @user_contact
end

Instance Method Details

#to_sObject

Returns a string representation of the relationship



246
247
248
249
250
# File 'lib/lusi_api/person/student.rb', line 246

def to_s
  contact = @user_contact ? @user_contact.contact_name : ''
  description = @staff_relationship ? "#{@staff_relationship.description}: " : ''
  "#{description}#{contact}"
end