Class: LUSI::API::Person::StaffMember

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

Overview

Represents a staff member in the LUSI API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, department: nil, faculty: nil, forename: nil, identity: nil, institution: nil, preferred_name: nil, surname: nil, title: nil) ⇒ void

Initialises a new StaffMember instance

Parameters:

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

    the parsed XML root of the staff member

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

    the lookup service for organisation unit resolution

  • department (LUSI::API::Organisation::Unit, nil) (defaults to: nil)

    the default department

  • faculty (LUSI::API::Organisation::Unit, nil) (defaults to: nil)

    the default faculty

  • forename (String, nil) (defaults to: nil)

    the default forename

  • identity (String, nil) (defaults to: nil)

    the default identity code

  • institution (LUSI::API::Organisation::Unit, nil) (defaults to: nil)

    the default institution

  • preferred_name (String, nil) (defaults to: nil)

    the default preferred name

  • surname (String, nil) (defaults to: nil)

    the default surname

  • title (String, nil) (defaults to: nil)

    the default title (honourific)



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/lusi_api/person/staff.rb', line 87

def initialize(xml = nil, lookup = nil, department: nil, faculty: nil, forename: nil, identity: nil,
               institution: nil, preferred_name: nil, surname: nil, title: nil)
  @department = LUSI::API::Core::XML.lookup(xml, lookup, :department, 'xmlns:Department/xmlns:Identity',
                                            department)
  @faculty = LUSI::API::Core::XML.lookup(xml, lookup, :faculty, 'xmlns:Faculty/xmlns:Identity', faculty)
  @forename = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Forename', forename)
  @identity = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Identity', identity)
  @institution = LUSI::API::Core::XML.lookup(xml, lookup, :institution, 'xmlns:Institution/xmlns:Identity',
                                             institution)
  @preferred_name = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:PreferredName', preferred_name)
  @surname = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Surname', surname)
  @title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Title', title)
end

Instance Attribute Details

#departmentLUSI::API::Organisation::Unit?

Returns the staff member’s associated department.

Returns:



65
66
67
# File 'lib/lusi_api/person/staff.rb', line 65

def department
  @department
end

#facultyLUSI::API::Organisation::Unit?

Returns the staff member’s associated faculty.

Returns:



69
70
71
# File 'lib/lusi_api/person/staff.rb', line 69

def faculty
  @faculty
end

#forenameString?

Returns the forename of the staff member.

Returns:

  • (String, nil)

    the forename of the staff member



57
58
59
# File 'lib/lusi_api/person/staff.rb', line 57

def forename
  @forename
end

#identityString?

Returns the identity code of the staff member.

Returns:

  • (String, nil)

    the identity code of the staff member



45
46
47
# File 'lib/lusi_api/person/staff.rb', line 45

def identity
  @identity
end

#institutionLUSI::API::Organisation::Unit?

Returns the staff member’s associated institution.

Returns:



73
74
75
# File 'lib/lusi_api/person/staff.rb', line 73

def institution
  @institution
end

#preferred_nameString?

Returns the preferred name of the staff member.

Returns:

  • (String, nil)

    the preferred name of the staff member



61
62
63
# File 'lib/lusi_api/person/staff.rb', line 61

def preferred_name
  @preferred_name
end

#surnameString?

Returns the surname of the staff member.

Returns:

  • (String, nil)

    the surname of the staff member



53
54
55
# File 'lib/lusi_api/person/staff.rb', line 53

def surname
  @surname
end

#titleString?

Returns the title (honourific) of the staff member.

Returns:

  • (String, nil)

    the title (honourific) of the staff member



49
50
51
# File 'lib/lusi_api/person/staff.rb', line 49

def title
  @title
end

Instance Method Details

#to_sString

Returns a string representation of the staff member (full name)

Returns:

  • (String)

    the string representation of the staff member (full name)



103
104
105
106
107
108
# File 'lib/lusi_api/person/staff.rb', line 103

def to_s
  str = "#{@title} #{@forename} #{@surname}"
  str.strip!
  str.squeeze!(' ')
  str
end