Module: Parliament::Decorators::SeatIncumbency

Defined in:
lib/parliament/decorators/seat_incumbency.rb

Overview

Decorator namespace for Grom::Node instances with type: id.ukpds.org/schema/SeatIncumbency

Instance Method Summary collapse

Instance Method Details

#constituencyGrom::Node?

Alias houseSeatHasConstituencyGroup with fallback.


45
46
47
# File 'lib/parliament/decorators/seat_incumbency.rb', line 45

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

#contact_pointsArray

Alias incumbencyHasContactPoint with fallback.


52
53
54
# File 'lib/parliament/decorators/seat_incumbency.rb', line 52

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

#current?Boolean

Checks if Grom::Node has an end date.


29
30
31
32
33
# File 'lib/parliament/decorators/seat_incumbency.rb', line 29

def current?
  has_end_date = respond_to?(:incumbencyEndDate)

  !has_end_date
end

#end_dateDateTime?

Alias incumbencyEndDate with fallback.


15
16
17
# File 'lib/parliament/decorators/seat_incumbency.rb', line 15

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

#houseGrom::Node?

Alias houseSeatHasHouse with fallback.


38
39
40
# File 'lib/parliament/decorators/seat_incumbency.rb', line 38

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

#memberGrom::Node?

Alias incumbencyHasMember with fallback.


59
60
61
# File 'lib/parliament/decorators/seat_incumbency.rb', line 59

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

#seatGrom::Node?

Alias seatIncumbencyHasHouseSeat with fallback.


22
23
24
# File 'lib/parliament/decorators/seat_incumbency.rb', line 22

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

#start_dateDateTime?

Alias incumbencyStartDate with fallback.


8
9
10
# File 'lib/parliament/decorators/seat_incumbency.rb', line 8

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