Module: Parliament::Decorators::HouseIncumbency

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

Overview

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

Instance Method Summary collapse

Instance Method Details

#contact_pointsArray

Alias incumbencyHasContactPoint with fallback.

Returns:

  • (Array, Array)

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


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

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

#current?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.


22
23
24
25
26
# File 'lib/parliament/decorators/house_incumbency.rb', line 22

def current?
  has_end_date = respond_to?(:incumbencyEndDate)

  !has_end_date
end

#end_dateDateTime?

Alias incumbencyEndDate with fallback.

Returns:

  • (DateTime, nil)

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


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

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

#houseGrom::Node?

Alias houseIncumbencyHasHouse with fallback.

Returns:

  • (Grom::Node, nil)

    the house of the Grom::Node or nil.


31
32
33
# File 'lib/parliament/decorators/house_incumbency.rb', line 31

def house
  respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
end

#memberGrom::Node?

Alias incumbencyHasMember with fallback.

Returns:

  • (Grom::Node, nil)

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


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

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

#start_dateDateTime?

Alias incumbencyStartDate with fallback.

Returns:

  • (DateTime, nil)

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


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

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