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

Version Path
parliament-grom-decorators-0.32.1 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.32.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.31.1 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.31.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.31.0.pre.rc lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.30.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.29.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.7 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.6 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.5 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.4 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.3 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.2 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.1 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.27.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.26.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.25.1 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.25.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.24.0 lib/parliament/grom/decorator/opposition_incumbency.rb
parliament-grom-decorators-0.23.0 lib/parliament/grom/decorator/opposition_incumbency.rb