Sha256: c48634e3cf539602509d8ec0d4f83ecd9b53f64aab9ce01e2e51cfe9d4eff8e1

Contents?: true

Size: 1.69 KB

Versions: 23

Compression:

Stored size: 1.69 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/House
      module House
        # Alias houseName with fallback.
        #
        # @return [String, String] the name of the Grom::Node or an empty string.
        def name
          respond_to?(:houseName) ? houseName : ''
        end

        # Alias houseSeatHasSeatIncumbency with fallback.
        #
        # @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
        def seat_incumbencies
          return @seat_incumbencies unless @seat_incumbencies.nil?

          seat_incumbencies = []
          seats.each do |seat|
            seat_incumbencies << seat.seat_incumbencies
          end

          @seat_incumbencies = seat_incumbencies.flatten.uniq
        end

        # Alias houseHasHouseSeat with fallback.
        #
        # @return [Array, Array] the house seats of the Grom::Node or an empty array.
        def seats
          respond_to?(:houseHasHouseSeat) ? houseHasHouseSeat : []
        end

        # Alias houseHasHouseIncumbency with fallback.
        #
        # @return [Array, Array] the house incumbencies of the Grom::Node or an empty array.
        def house_incumbencies
          respond_to?(:houseHasHouseIncumbency) ? houseHasHouseIncumbency : []
        end

        # Is this the lords?
        #
        # @return Boolean is the house the lords?
        def lords?
          name == 'House of Lords'
        end

        # Is this the commons?
        #
        # @return Boolean is the house the commons?
        def commons?
          name == 'House of Commons'
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.32.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.32.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.31.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.31.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.31.0.pre.rc lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.30.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.29.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.7 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.6 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.5 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.4 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.3 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.2 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.27.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.26.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.25.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.25.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.24.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.23.0 lib/parliament/grom/decorator/house.rb