Sha256: e1663ac78c8094b8ccfcbb5e0a1ab13d1ec3285c3f10e7ac946519c55b3a8e79

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/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

5 entries across 5 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.10.1 lib/parliament/grom/decorator/formal_body.rb
parliament-grom-decorators-0.10.0 lib/parliament/grom/decorator/formal_body.rb
parliament-grom-decorators-0.9.0 lib/parliament/grom/decorator/formal_body.rb
parliament-grom-decorators-0.8.0 lib/parliament/grom/decorator/formal_body.rb
parliament-grom-decorators-0.7.0 lib/parliament/grom/decorator/formal_body.rb