Sha256: 93745e0b424ad2b7be344b13e80e5f35112d88c01e47c0a68cc736f371433f54

Contents?: true

Size: 934 Bytes

Versions: 5

Compression:

Stored size: 934 Bytes

Contents

module Parliament
  module Decorators
    module SeatIncumbency
      def start_date
        respond_to?(:seatIncumbencyStartDate) ? DateTime.parse(seatIncumbencyStartDate) : nil
      end

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

      def seat
        respond_to?(:seatIncumbencyHasHouseSeat) ? seatIncumbencyHasHouseSeat.first : nil
      end

      def member
        respond_to?(:seatIncumbencyHasMember) ? seatIncumbencyHasMember.first : nil
      end

      def current?
        has_end_date = respond_to?(:seatIncumbencyEndDate)

        !has_end_date
      end

      def house
        seat.nil? ? nil : seat.house
      end

      def constituency
        seat.nil? ? nil : seat.constituency
      end

      def contact_points
        respond_to?(:seatIncumbencyHasContactPoint) ? seatIncumbencyHasContactPoint : []
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
parliament-ruby-0.4.1 lib/parliament/decorators/seat_incumbency.rb
parliament-ruby-0.4.0 lib/parliament/decorators/seat_incumbency.rb
parliament-ruby-0.3.0 lib/parliament/decorators/seat_incumbency.rb
parliament-ruby-0.2.2 lib/parliament/decorators/seat_incumbency.rb
parliament-ruby-0.2.1 lib/parliament/decorators/seat_incumbency.rb