Module: Parliament::Grom::Decorator::SeatIncumbency

Defined in:
lib/parliament/grom/decorator/seat_incumbency.rb

Overview

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

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#constituencyGrom::Node?

Alias houseSeatHasConstituencyGroup with fallback.

Returns:

  • (Grom::Node, nil)

    the constituency of the Grom::Node or nil.

Since:

  • 0.1.0



51
52
53
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 51

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

#contact_pointsArray

Alias incumbencyHasContactPoint with fallback.

Returns:

  • (Array, Array)

    the contact points of the Grom::Node or an empty array.

Since:

  • 0.1.0



58
59
60
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 58

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

#current?Boolean

Checks if Grom::Node has no end date.

Returns:

  • (Boolean)

    a boolean depending on whether or not the Grom::Node has an end date.

Since:

  • 0.1.0



30
31
32
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 30

def current?
  !former?
end

#end_dateDateTime?

Alias incumbencyEndDate with fallback.

Returns:

  • (DateTime, nil)

    the end date of the Grom::Node or nil.

Since:

  • 0.1.0



16
17
18
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 16

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

#former?Boolean

Checks if Grom::Node has an end date.

Returns:

  • (Boolean)

    a boolean depending on whether or not the Grom::Node has an end date.

Since:

  • 0.1.0



37
38
39
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 37

def former?
  respond_to?(:incumbencyEndDate)
end

#houseGrom::Node?

Alias houseSeatHasHouse with fallback.

Returns:

  • (Grom::Node, nil)

    the house of the Grom::Node or nil.

Since:

  • 0.1.0



44
45
46
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 44

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

#memberGrom::Node?

Alias incumbencyHasMember with fallback.

Returns:

  • (Grom::Node, nil)

    the member connected to the Grom::Node or nil.

Since:

  • 0.1.0



65
66
67
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 65

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

#seatGrom::Node?

Alias seatIncumbencyHasHouseSeat with fallback.

Returns:

  • (Grom::Node, nil)

    the seat of the Grom::Node or nil.

Since:

  • 0.1.0



23
24
25
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 23

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

#start_dateDateTime?

Alias incumbencyStartDate with fallback.

Returns:

  • (DateTime, nil)

    the start date of the Grom::Node or nil.

Since:

  • 0.1.0



9
10
11
# File 'lib/parliament/grom/decorator/seat_incumbency.rb', line 9

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