Sha256: 6b07c0ce1ff019f5c58eceea07ff85d0a7748adff2aef97d33213d17914c4b70

Contents?: true

Size: 1015 Bytes

Versions: 9

Compression:

Stored size: 1015 Bytes

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Answer.
      module Answer
        include Helpers::DateHelper
        # Alias answerText with fallback.
        #
        # @return [String, String] the text of the Grom::Node or an empty string.
        def text
          respond_to?(:answerText) ? answerText : ''
        end

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

        # Alias answerHasAnsweringPerson with fallback.
        #
        # @return [Grom::Node, nil] the answering_person of the Grom::Node or nil.
        def answering_person
          respond_to?(:answerHasAnsweringPerson) ? answerHasAnsweringPerson.first : nil
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.27.4 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.27.3 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.27.2 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.27.1 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.27.0 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.26.0 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.25.1 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.25.0 lib/parliament/grom/decorator/answer.rb
parliament-grom-decorators-0.24.0 lib/parliament/grom/decorator/answer.rb