Module: Parliament::Grom::Decorator::HouseIncumbency

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

Overview

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

Since:

  • 0.1.0

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.

Since:

  • 0.1.0



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

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.

Since:

  • 0.1.0



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

def current?
  end_date.nil?
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/house_incumbency.rb', line 16

def end_date
  @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.

Since:

  • 0.1.0



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

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.

Since:

  • 0.1.0



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

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.

Since:

  • 0.1.0



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

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