Sha256: 5ac83894938e7d5e630194ca719ff732ddc3da08207946beb1e0f2b2c6544475

Contents?: true

Size: 1.61 KB

Versions: 10

Compression:

Stored size: 1.61 KB

Contents

module Parliament
  module Decorators
    module ConstituencyGroup
      def name
        respond_to?(:constituencyGroupName) ? constituencyGroupName : ''
      end

      def start_date
        respond_to?(:constituencyGroupStartDate) ? DateTime.parse(constituencyGroupStartDate) : nil
      end

      def end_date
        respond_to?(:constituencyGroupEndDate) ? DateTime.parse(constituencyGroupEndDate) : nil
      end

      def seats
        respond_to?(:constituencyGroupHasHouseSeat) ? constituencyGroupHasHouseSeat : []
      end

      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

      def members
        return @members unless @members .nil?

        members = []
        seat_incumbencies.each do |seat_incumbency|
          members << seat_incumbency.member
        end

        @members = members.flatten.uniq
      end

      def area
        respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil
      end

      def contact_points
        return @contact_points unless @contact_points.nil?

        contact_points = []
        seat_incumbencies.each do |seat_incumbency|
          contact_points << seat_incumbency.contact_points
        end

        @contact_points = contact_points.flatten.uniq
      end

      def current?
        has_end_date = respond_to?(:constituencyGroupEndDate)

        !has_end_date
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
parliament-ruby-0.5.19 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.18 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.17 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.16 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.15 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.14 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.13 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.12 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.8 lib/parliament/decorators/constituency_group.rb
parliament-ruby-0.5.7 lib/parliament/decorators/constituency_group.rb