Module: Parliament::Grom::Decorator::OppositionIncumbency

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

Overview

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

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Helpers::DateHelper

#date_range

Instance Method Details

#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/opposition_incumbency.rb', line 25

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



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

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

#opposition_positionGrom::Node?

Alias oppositionIncumbencyHasGovernmentPosition with fallback.

Returns:

  • (Grom::Node, nil)

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

Since:

  • 0.1.0



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

def opposition_position
  respond_to?(:oppositionIncumbencyHasOppositionPosition) ? oppositionIncumbencyHasOppositionPosition&.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



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

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