Sha256: bf01d5b219c510a1d67be4771f243f7274f91d3c5d0c17a6644523be5a24cee1

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/FormalBody.
      # rubocop:disable ModuleLength
      module FormalBody
        include Helpers::DateHelper

        # Checks if Grom::Node has a name.
        #
        # @return [String, String] a string depending on whether or not the Grom::Node has a name.
        def name
          @name ||= respond_to?(:formalBodyName) ? formalBodyName : ''
        end

        # Alias formalBodyStartDate with fallback.
        #
        # @return [DateTime, nil] the start date of the Grom::Node or nil.
        def start_date
          @start_date ||= respond_to?(:formalBodyStartDate) ? DateTime.parse(formalBodyStartDate) : nil
        end

        # Alias formalBodyEndDate with fallback.
        #
        # @return [DateTime, nil] the end date of the Grom::Node or nil.
        def end_date
          @end_date ||= respond_to?(:formalBodyEndDate) ? DateTime.parse(formalBodyEndDate) : 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
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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