Module: Parliament::Grom::Decorator::Party

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

Overview

Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/Party

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#commons_countInteger?

Alias commonsCount with fallback.

Returns:

  • (Integer, nil)

    the count of Members of the House of Commons of the Grom::Node or nil.

Since:

  • 0.1.0



30
31
32
# File 'lib/parliament/grom/decorator/party.rb', line 30

def commons_count
  respond_to?(:commonsCount) ? commonsCount.to_i : nil
end

#current?Boolean

Checks if Grom::Node has any current members.

Returns:

  • (Boolean)

    a boolean depending on whether or not the Grom::Node has any current members.

Since:

  • 0.1.0



44
45
46
47
48
# File 'lib/parliament/grom/decorator/party.rb', line 44

def current?
  no_current_total_members = member_count.nil? || member_count.zero?
  no_current_separate_members = (commons_count.nil? || commons_count.zero?) && (lords_count.nil? || lords_count.zero?)
  !no_current_total_members || !no_current_separate_members
end

#lords_countInteger?

Alias lordsCount with fallback.

Returns:

  • (Integer, nil)

    the count of Members of the House of Lords of the Grom::Node or nil.

Since:

  • 0.1.0



37
38
39
# File 'lib/parliament/grom/decorator/party.rb', line 37

def lords_count
  respond_to?(:lordsCount) ? lordsCount.to_i : nil
end

#member_countInteger?

Alias count with fallback.

Returns:

  • (Integer, nil)

    the count of members of the Grom::Node or nil.

Since:

  • 0.1.0



23
24
25
# File 'lib/parliament/grom/decorator/party.rb', line 23

def member_count
  respond_to?(:count) ? count.to_i : nil
end

#nameString

Alias partyName with fallback.

Returns:

  • (String, String)

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

Since:

  • 0.1.0



9
10
11
# File 'lib/parliament/grom/decorator/party.rb', line 9

def name
  respond_to?(:partyName) ? partyName : ''
end

#party_membershipsArray

Alias partyHasPartyMembership with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



16
17
18
# File 'lib/parliament/grom/decorator/party.rb', line 16

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