class LUSI::API::Person::Relationship

Represents a student's relationship with a member of staff

Attributes

staff_relationship[RW]

@!attribute [rw] staff_relationship

@return [LUSI::API::Core::Code, nil] the staff relationship type
user_contact[RW]

@!attribute [rw] user_contact

@return [LUSI::API::Person::UserContact, nil] the related person's contact details

Public Class Methods

new(xml = nil, lookup = nil, staff_relationship: nil, user_contact: nil) click to toggle source

Initialises a new Relationship instance @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the relationship @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param staff_relationship [LUSI::API::Core::Code, nil] the default staff relationship code @param user_contact [LUSI::API::Person::UserContact, nil] the default related person's contact details

# 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

Public Instance Methods

to_s() click to toggle source

Returns a string representation of the relationship

# 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