Sha256: bb1deaac07d7112216302822eecdfa7bca76780ed33980f12332ab64b9a0e803

Contents?: true

Size: 1.85 KB

Versions: 22

Compression:

Stored size: 1.85 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Party
      module Party
        # Alias partyName with fallback.
        #
        # @return [String, String] the party name of the Grom::Node or an empty string.
        def name
          respond_to?(:partyName) ? partyName : ''
        end

        # Alias partyHasPartyMembership with fallback.
        #
        # @return [Array, Array] the party memberships of the Grom::Node or an empty array.
        def party_memberships
          respond_to?(:partyHasPartyMembership) ? partyHasPartyMembership : []
        end

        # Alias count with fallback.
        #
        # @return [Integer, nil] the count of members of the Grom::Node or nil.
        def member_count
          respond_to?(:count) ? count.to_i : nil
        end

        # Alias commonsCount with fallback.
        #
        # @return [Integer, nil] the count of Members of the House of Commons of the Grom::Node or nil.
        def commons_count
          respond_to?(:commonsCount) ? commonsCount.to_i : nil
        end

        # Alias lordsCount with fallback.
        #
        # @return [Integer, nil] the count of Members of the House of Lords of the Grom::Node or nil.
        def lords_count
          respond_to?(:lordsCount) ? lordsCount.to_i : nil
        end

        # Checks if Grom::Node has any current members.
        #
        # @return [Boolean] a boolean depending on whether or not the Grom::Node has any current members.
        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
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.10.1 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.10.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.9.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.8.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.7.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.6.1 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.6.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.4.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.3.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.8 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.7 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.6.pre lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.5.pre lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.4.pre lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.3 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.1 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.2.0 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.1.8 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.1.7 lib/parliament/grom/decorator/party.rb
parliament-grom-decorators-0.1.6 lib/parliament/grom/decorator/party.rb