Class: MaisPersonClient::Affiliations
- Inherits:
-
Object
- Object
- MaisPersonClient::Affiliations
show all
- Defined in:
- lib/mais_person_client/affiliations.rb
Overview
Model for Affiliations from the MAIS Person API
Defined Under Namespace
Classes: Address, AffData, AffiliationRecord, Department, Organization, Place, Telephone
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Affiliations.
19
20
21
22
|
# File 'lib/mais_person_client/affiliations.rb', line 19
def initialize(xml)
@xml = Nokogiri::XML(xml)
@xml.remove_namespaces!
end
|
Instance Attribute Details
#xml ⇒ Object
Returns the value of attribute xml.
17
18
19
|
# File 'lib/mais_person_client/affiliations.rb', line 17
def xml
@xml
end
|
Instance Method Details
#active_affiliations ⇒ Object
71
72
73
|
# File 'lib/mais_person_client/affiliations.rb', line 71
def active_affiliations
affiliations.reject { |aff| aff.type&.include?('nonactive') }
end
|
#affiliations ⇒ Object
Affiliations (multiple possible)
58
59
60
|
# File 'lib/mais_person_client/affiliations.rb', line 58
def affiliations
xml.xpath('//affiliation').map { |aff_node| build_affiliation(aff_node) }
end
|
#card ⇒ Object
25
26
27
|
# File 'lib/mais_person_client/affiliations.rb', line 25
def card
xml.root['card']
end
|
#faculty_affiliations ⇒ Object
63
64
65
|
# File 'lib/mais_person_client/affiliations.rb', line 63
def faculty_affiliations
affiliations.select { |aff| aff.type&.include?('faculty') }
end
|
#listing ⇒ Object
29
30
31
|
# File 'lib/mais_person_client/affiliations.rb', line 29
def listing
xml.root['listing']
end
|
#name_attr ⇒ Object
33
34
35
|
# File 'lib/mais_person_client/affiliations.rb', line 33
def name_attr
xml.root['name']
end
|
#org_ids ⇒ Object
79
80
81
|
# File 'lib/mais_person_client/affiliations.rb', line 79
def org_ids
xml.xpath('//organization/@adminid').map(&:value).uniq.compact
end
|
#primary_affiliation ⇒ Object
75
76
77
|
# File 'lib/mais_person_client/affiliations.rb', line 75
def primary_affiliation
affiliations.find { |aff| aff.affnum == '1' }
end
|
#primary_org_code ⇒ Object
83
84
85
86
|
# File 'lib/mais_person_client/affiliations.rb', line 83
def primary_org_code
org_node = xml.at_xpath("//affiliation[@affnum='1']//organization")
org_node ? org_node['adminid'] : nil
end
|
#regid ⇒ Object
37
38
39
|
# File 'lib/mais_person_client/affiliations.rb', line 37
def regid
xml.root['regid']
end
|
#relationship ⇒ Object
41
42
43
|
# File 'lib/mais_person_client/affiliations.rb', line 41
def relationship
xml.root['relationship']
end
|
#source ⇒ Object
45
46
47
|
# File 'lib/mais_person_client/affiliations.rb', line 45
def source
xml.root['source']
end
|
#student_affiliations ⇒ Object
67
68
69
|
# File 'lib/mais_person_client/affiliations.rb', line 67
def student_affiliations
affiliations.select { |aff| aff.type&.include?('student') }
end
|
#sunetid ⇒ Object
49
50
51
|
# File 'lib/mais_person_client/affiliations.rb', line 49
def sunetid
xml.root['sunetid']
end
|
#univid ⇒ Object
53
54
55
|
# File 'lib/mais_person_client/affiliations.rb', line 53
def univid
xml.root['univid']
end
|