Module: Parliament::Grom::Decorator::Answer

Includes:
Helpers::DateHelper
Defined in:
lib/parliament/grom/decorator/answer.rb

Overview

Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/Answer.

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Helpers::DateHelper

#date_range

Instance Method Details

#answer_given_dateDateTime?

Alias answerGivenDate with fallback.

Returns:

  • (DateTime, nil)

    the answer date of the Grom::Node or nil.

Since:

  • 0.1.0



17
18
19
# File 'lib/parliament/grom/decorator/answer.rb', line 17

def answer_given_date
  @answer_given_date ||= respond_to?(:answerGivenDate) ? DateTime.parse(answerGivenDate) : nil
end

#answering_personGrom::Node?

Alias answerHasAnsweringPerson with fallback.

Returns:

  • (Grom::Node, nil)

    the answering_person of the Grom::Node or nil.

Since:

  • 0.1.0



24
25
26
# File 'lib/parliament/grom/decorator/answer.rb', line 24

def answering_person
  respond_to?(:answerHasAnsweringPerson) ? answerHasAnsweringPerson.first : nil
end

#questionGrom::Node?

Alias answerHasQuestion with fallback.

Returns:

  • (Grom::Node, nil)

    the question of the Grom::Node or nil.

Since:

  • 0.1.0



31
32
33
# File 'lib/parliament/grom/decorator/answer.rb', line 31

def question
  respond_to?(:answerHasQuestion) ? answerHasQuestion.first : nil
end

#textString

Alias answerText with fallback.

Returns:

  • (String, String)

    the text of the Grom::Node or an empty string.

Since:

  • 0.1.0



10
11
12
# File 'lib/parliament/grom/decorator/answer.rb', line 10

def text
  respond_to?(:answerText) ? answerText : ''
end