Sha256: 2b62e516f6fe94178d53c1c23e5124e698c9f64488b7a54cb5cf3646bb2985a7

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/HouseIncumbency
      module HouseIncumbency
        # 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 houseIncumbencyHasHouse with fallback.
        #
        # @return [Grom::Node, nil] the house of the Grom::Node or nil.
        def house
          respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
        end

        # Alias incumbencyHasMember with fallback.
        #
        # @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
        def member
          respond_to?(:incumbencyHasMember) ? incumbencyHasMember.first : nil
        end

        # Alias incumbencyHasContactPoint with fallback.
        #
        # @return [Array, Array] the contact points of the Grom::Node or an empty array.
        def contact_points
          respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.1.6 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.1.5 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.1.4 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.1.3 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.1.2 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.1.1 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.1.0 lib/parliament/grom/decorator/house_incumbency.rb
parliament-grom-decorators-0.0.1.pre lib/parliament/grom/decorator/house_incumbency.rb