Sha256: acdba88ca76599d3c7fa821d182ce93b161dbf9a9d7f83aa48fa63372d5e65e2

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/governmentIncumbency.
      # rubocop:disable ModuleLength
      module GovernmentIncumbency
        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 governmentIncumbencyHasGovernmentPosition with fallback.
        #
        # @return [Grom::Node, nil] the start date of the Grom::Node or nil.
        def government_position
          respond_to?(:governmentIncumbencyHasGovernmentPosition) ? governmentIncumbencyHasGovernmentPosition&.first : nil
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.21.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.19.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.18.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.17.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.16.4 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.16.3 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.16.1 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.16.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.15.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.14.1 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.14.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.13.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.12.1 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.12.0 lib/parliament/grom/decorator/government_incumbency.rb
parliament-grom-decorators-0.11.0 lib/parliament/grom/decorator/government_incumbency.rb