Sha256: 0ede22b7040c9ac4a1ae700d41fb9e1df62a4b99a2be4bb376475cdc4348b94d
Contents?: true
Size: 1.32 KB
Versions: 34
Compression:
Stored size: 1.32 KB
Contents
module Parliament module Grom module Decorator # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/oppositionIncumbency. module OppositionIncumbency include Helpers::DateHelper # Alias incumbencyStartDate with fallback. # # @return [DateTime, nil] the start date of the Grom::Node or nil. def start_date @start_date ||= respond_to?(:incumbencyStartDate) ? DateTime.parse(incumbencyStartDate) : nil end # Alias incumbencyEndDate with fallback. # # @return [DateTime, nil] the end date of the Grom::Node or nil. def end_date @end_date ||= respond_to?(:incumbencyEndDate) ? DateTime.parse(incumbencyEndDate) : nil end # Checks if Grom::Node has an end date. # # @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date. def current? end_date.nil? end # Alias oppositionIncumbencyHasGovernmentPosition with fallback. # # @return [Grom::Node, nil] the start date of the Grom::Node or nil. def opposition_position respond_to?(:oppositionIncumbencyHasOppositionPosition) ? oppositionIncumbencyHasOppositionPosition&.first : nil end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems