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

Includes:
Helpers::DateHelper
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

Methods included from Helpers::DateHelper

#date_range

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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