Module: Parliament::Grom::Decorator::ParliamentaryIncumbency

Includes:
Helpers::DateHelper
Defined in:
lib/parliament/grom/decorator/parliamentary_incumbency.rb

Overview

Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/ParliamentaryIncumbency

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Helpers::DateHelper

#date_range

Instance Method Details

#contact_pointsArray

Alias parliamentaryIncumbencyHasContactPoint with fallback.

Returns:

  • (Array, Array)

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

Since:

  • 0.1.0



39
40
41
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 39

def contact_points
  respond_to?(:parliamentaryIncumbencyHasContactPoint) ? parliamentaryIncumbencyHasContactPoint : []
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



25
26
27
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 25

def current?
  end_date.nil?
end

#end_dateDateTime?

Alias parliamentaryIncumbencyEndDate with fallback.

Returns:

  • (DateTime, nil)

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

Since:

  • 0.1.0



18
19
20
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 18

def end_date
  @end_date ||= respond_to?(:parliamentaryIncumbencyEndDate) ? DateTime.parse(parliamentaryIncumbencyEndDate) : nil
end

#houseGrom::Node?

Alias houseIncumbencyHasHouse with fallback.

Returns:

  • (Grom::Node, nil)

    the house of the Grom::Node or nil.

Since:

  • 0.1.0



53
54
55
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 53

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

#memberGrom::Node?

Alias parliamentaryIncumbencyHasMember with fallback.

Returns:

  • (Grom::Node, nil)

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

Since:

  • 0.1.0



32
33
34
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 32

def member
  respond_to?(:parliamentaryIncumbencyHasMember) ? parliamentaryIncumbencyHasMember.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



46
47
48
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 46

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

#start_dateDateTime?

Alias parliamentaryIncumbencyStartDate with fallback.

Returns:

  • (DateTime, nil)

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

Since:

  • 0.1.0



11
12
13
# File 'lib/parliament/grom/decorator/parliamentary_incumbency.rb', line 11

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