Module: Parliament::Decorators::Person

Defined in:
lib/parliament/decorators/person.rb

Overview

Decorator namespace for Grom::Node instances with type: id.ukpds.org/schema/Person

Instance Method Summary collapse

Instance Method Details

#constituenciesArray

Alias houseSeatHasConstituencyGroup with fallback.

Returns:

  • (Array, Array)

    the constituencies of the Grom::Node or an empty array.


107
108
109
110
111
112
113
114
115
116
# File 'lib/parliament/decorators/person.rb', line 107

def constituencies
  return @constituencies unless @constituencies.nil?

  constituencies = []
  seats.each do |seat|
    constituencies << seat.constituency
  end

  @constituencies = constituencies.flatten.uniq
end

#contact_pointsArray

Alias personHasContactPoint with fallback.

Returns:

  • (Array, Array)

    the contact points of the Grom::Node or an empty array.


142
143
144
# File 'lib/parliament/decorators/person.rb', line 142

def contact_points
  respond_to?(:personHasContactPoint) ? personHasContactPoint : []
end

#date_of_birthDateTime?

Alias personDateOfBirth with fallback.

Returns:

  • (DateTime, nil)

    the date of birth of the Grom::Node or nil.


29
30
31
# File 'lib/parliament/decorators/person.rb', line 29

def date_of_birth
  respond_to?(:personDateOfBirth) ? DateTime.parse(personDateOfBirth) : nil
end

#display_nameString

Alias F31CBD81AD8343898B49DC65743F0BDF with fallback.

Returns:

  • (String, String)

    the display name of the Grom::Node or the full name.


183
184
185
# File 'lib/parliament/decorators/person.rb', line 183

def display_name
  respond_to?(:F31CBD81AD8343898B49DC65743F0BDF) ? self.F31CBD81AD8343898B49DC65743F0BDF : full_name
end

#family_nameString

Alias personFamilyName with fallback.

Returns:

  • (String, String)

    the family name of the Grom::Node or an empty string.


15
16
17
# File 'lib/parliament/decorators/person.rb', line 15

def family_name
  respond_to?(:personFamilyName) ? personFamilyName : ''
end

#full_nameString

Builds a full name using personGivenName and personFamilyName.

Returns:

  • (String, String)

    the full name of the Grom::Node or an empty string.


36
37
38
39
40
41
# File 'lib/parliament/decorators/person.rb', line 36

def full_name
  full_name = ''
  full_name += respond_to?(:personGivenName) ? personGivenName + ' ' : ''
  full_name += respond_to?(:personFamilyName) ? personFamilyName : ''
  full_name.rstrip
end

#full_titleString

Alias D79B0BAC513C4A9A87C9D5AFF1FC632F with fallback.

Returns:

  • (String, String)

    the full title of the Grom::Node or an empty string.


176
177
178
# File 'lib/parliament/decorators/person.rb', line 176

def full_title
  respond_to?(:D79B0BAC513C4A9A87C9D5AFF1FC632F) ? self.D79B0BAC513C4A9A87C9D5AFF1FC632F : ''
end

#genderArray

Alias genderIdentityHasGender with fallback.

Returns:

  • (Array, Array)

    the gender of the Grom::Node or nil.


156
157
158
# File 'lib/parliament/decorators/person.rb', line 156

def gender
  gender_identities.empty? ? nil : gender_identities.first.gender
end

#gender_identitiesArray

Alias personHasGenderIdentity with fallback.

Returns:

  • (Array, Array)

    the gender identities of the Grom::Node or an empty array.


149
150
151
# File 'lib/parliament/decorators/person.rb', line 149

def gender_identities
  respond_to?(:personHasGenderIdentity) ? personHasGenderIdentity : []
end

#given_nameString

Alias personGivenName with fallback.

Returns:

  • (String, String)

    the given name of the Grom::Node or an empty string.


8
9
10
# File 'lib/parliament/decorators/person.rb', line 8

def given_name
  respond_to?(:personGivenName) ? personGivenName : ''
end

#house_incumbenciesArray

Alias memberHasIncumbency with fallback.

Returns:

  • (Array, Array)

    the house incumbencies of the Grom::Node or an empty array.


64
65
66
67
68
69
70
# File 'lib/parliament/decorators/person.rb', line 64

def house_incumbencies
  if respond_to?(:memberHasIncumbency)
    memberHasIncumbency.select { |inc| inc.type == 'http://id.ukpds.org/schema/HouseIncumbency' }
  else
    []
  end
end

#housesArray

Alias houseSeatHasHouse with fallback.

Returns:

  • (Array, Array)

    the houses of the Grom::Node or an empty array.


89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/parliament/decorators/person.rb', line 89

def houses
  return @houses unless @houses.nil?

  houses = []
  seats.each do |seat|
    houses << seat.house
  end

  house_incumbencies.each do |inc|
    houses << inc.house
  end

  @houses = houses.flatten.uniq
end

#incumbenciesArray

Alias memberHasIncumbency with fallback.

Returns:

  • (Array, Array)

    all the incumbencies of the Grom::Node or an empty array.


46
47
48
# File 'lib/parliament/decorators/person.rb', line 46

def incumbencies
  respond_to?(:memberHasIncumbency) ? memberHasIncumbency : []
end

#other_nameString

Alias personOtherNames with fallback.

Returns:

  • (String, String)

    the other names of the Grom::Node or an empty string.


22
23
24
# File 'lib/parliament/decorators/person.rb', line 22

def other_name
  respond_to?(:personOtherNames) ? personOtherNames : ''
end

#partiesArray

Alias partyMembershipHasParty with fallback.

Returns:

  • (Array, Array)

    the parties of the Grom::Node or an empty array.


128
129
130
131
132
133
134
135
136
137
# File 'lib/parliament/decorators/person.rb', line 128

def parties
  return @parties unless @parties.nil?

  parties = []
  party_memberships.each do |party_membership|
    parties << party_membership.party
  end

  @parties = parties.flatten.uniq.compact
end

#party_membershipsArray

Alias partyMemberHasPartyMembership with fallback.

Returns:

  • (Array, Array)

    the party memberships of the Grom::Node or an empty array.


121
122
123
# File 'lib/parliament/decorators/person.rb', line 121

def party_memberships
  respond_to?(:partyMemberHasPartyMembership) ? partyMemberHasPartyMembership : []
end

#seat_incumbenciesArray

Alias memberHasIncumbency with fallback.

Returns:

  • (Array, Array)

    the seat incumbencies of the Grom::Node or an empty array.


53
54
55
56
57
58
59
# File 'lib/parliament/decorators/person.rb', line 53

def seat_incumbencies
  if respond_to?(:memberHasIncumbency)
    memberHasIncumbency.select { |inc| inc.type == 'http://id.ukpds.org/schema/SeatIncumbency' }
  else
    []
  end
end

#seatsArray

Alias seatIncumbencyHasHouseSeat with fallback.

Returns:

  • (Array, Array)

    the seats of the Grom::Node or an empty array.


75
76
77
78
79
80
81
82
83
84
# File 'lib/parliament/decorators/person.rb', line 75

def seats
  return @seats unless @seats.nil?

  seats = []
  seat_incumbencies.each do |incumbency|
    seats << incumbency.seat if incumbency.respond_to?(:seat)
  end

  @seats = seats.flatten.uniq
end

#sort_nameString

Alias A5EE13ABE03C4D3A8F1A274F57097B6C with fallback.

Returns:

  • (String, String)

    the sort name of the Grom::Node or an empty string.


190
191
192
# File 'lib/parliament/decorators/person.rb', line 190

def sort_name
  respond_to?(:A5EE13ABE03C4D3A8F1A274F57097B6C) ? self.A5EE13ABE03C4D3A8F1A274F57097B6C : ''
end

#statusesHash

Checks the statuses of the Grom::Node.

Returns:

  • (Hash, Hash)

    the statuses of the Grom::Node or an empty hash.


163
164
165
166
167
168
169
170
171
# File 'lib/parliament/decorators/person.rb', line 163

def statuses
  return @statuses unless @statuses.nil?

  statuses = {}
  statuses[:house_membership_status] = house_membership_status
  statuses[:general_membership_status] = general_membership_status

  @statuses = statuses
end