Module: Parliament::Grom::Decorator::Person

Defined in:
lib/parliament/grom/decorator/person.rb

Overview

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

Since:

  • 0.1.0

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.

Since:

  • 0.1.0



86
87
88
# File 'lib/parliament/grom/decorator/person.rb', line 86

def constituencies
  @constituencies ||= seats.map(&:constituency).flatten.uniq.compact
end

#contact_pointsArray

Alias personHasContactPoint with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



107
108
109
# File 'lib/parliament/grom/decorator/person.rb', line 107

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.

Since:

  • 0.1.0



31
32
33
# File 'lib/parliament/grom/decorator/person.rb', line 31

def date_of_birth
  @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.

Since:

  • 0.1.0



148
149
150
# File 'lib/parliament/grom/decorator/person.rb', line 148

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.

Since:

  • 0.1.0



17
18
19
# File 'lib/parliament/grom/decorator/person.rb', line 17

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.

Since:

  • 0.1.0



38
39
40
41
42
43
44
45
46
# File 'lib/parliament/grom/decorator/person.rb', line 38

def full_name
  return @full_name unless @full_name.nil?

  full_name = []
  full_name << personGivenName if respond_to?(:personGivenName)
  full_name << personFamilyName if respond_to?(:personFamilyName)

  @full_name = full_name.join(' ')
end

#full_titleString

Alias D79B0BAC513C4A9A87C9D5AFF1FC632F with fallback.

Returns:

  • (String, String)

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

Since:

  • 0.1.0



141
142
143
# File 'lib/parliament/grom/decorator/person.rb', line 141

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.

Since:

  • 0.1.0



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

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.

Since:

  • 0.1.0



114
115
116
# File 'lib/parliament/grom/decorator/person.rb', line 114

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.

Since:

  • 0.1.0



10
11
12
# File 'lib/parliament/grom/decorator/person.rb', line 10

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.

Since:

  • 0.1.0



65
66
67
# File 'lib/parliament/grom/decorator/person.rb', line 65

def house_incumbencies
  @house_incumbencies ||= incumbencies.select { |inc| inc.type == 'http://id.ukpds.org/schema/HouseIncumbency' }
end

#housesArray

Alias houseSeatHasHouse with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



79
80
81
# File 'lib/parliament/grom/decorator/person.rb', line 79

def houses
  @houses ||= [seats.map(&:house), house_incumbencies.map(&:house)].flatten.uniq.compact
end

#incumbenciesArray

Alias memberHasIncumbency with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



51
52
53
# File 'lib/parliament/grom/decorator/person.rb', line 51

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.

Since:

  • 0.1.0



24
25
26
# File 'lib/parliament/grom/decorator/person.rb', line 24

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.

Since:

  • 0.1.0



100
101
102
# File 'lib/parliament/grom/decorator/person.rb', line 100

def parties
  @parties ||= party_memberships.map(&:party).flatten.uniq.compact
end

#party_membershipsArray

Alias partyMemberHasPartyMembership with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



93
94
95
# File 'lib/parliament/grom/decorator/person.rb', line 93

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.

Since:

  • 0.1.0



58
59
60
# File 'lib/parliament/grom/decorator/person.rb', line 58

def seat_incumbencies
  @seat_incumbencies ||= incumbencies.select { |inc| inc.type == 'http://id.ukpds.org/schema/SeatIncumbency' }
end

#seatsArray

Alias seatIncumbencyHasHouseSeat with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



72
73
74
# File 'lib/parliament/grom/decorator/person.rb', line 72

def seats
  @seats ||= seat_incumbencies.map(&:seat).flatten.uniq.compact
end

#sort_nameString

Alias A5EE13ABE03C4D3A8F1A274F57097B6C with fallback.

Returns:

  • (String, String)

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

Since:

  • 0.1.0



155
156
157
# File 'lib/parliament/grom/decorator/person.rb', line 155

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.

Since:

  • 0.1.0



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

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