Class: TypedForm::FormData::Answers
- Inherits:
-
Object
- Object
- TypedForm::FormData::Answers
- Extended by:
- Forwardable
- Defined in:
- lib/typed_form/form_data/answers.rb
Overview
A collection class which takes a collection of answers to a form, and associates the questions with answers.
Instance Attribute Summary collapse
-
#input_questions ⇒ Object
readonly
Returns the value of attribute input_questions.
-
#parsed_questions ⇒ Arendelle
readonly
An immutable object representing the question data from the form.
-
#parsed_response ⇒ Arendelle
readonly
An immutable object representing the submission data from the form.
Class Method Summary collapse
-
.collate(parsed_response:, parsed_questions:, input_questions:) ⇒ Array<Question>
Builds a collection of Questions, with text extrapolated to support "piped" questions (i.e. "What is the name of your {answer_42}").
Instance Method Summary collapse
-
#answers ⇒ Arendelle
Parsed Questions from Typeform Data API JSON.
-
#metadata ⇒ Arendelle
Parsed Metadata from Typeform Data API JSON.
-
#questions ⇒ Array<Question>
Iterates through the existing collection of input questions to build a set of question value objects.
-
#token ⇒ String
Date form was submitted, in UTC.
Instance Attribute Details
#input_questions ⇒ Object (readonly)
Returns the value of attribute input_questions.
27 28 29 |
# File 'lib/typed_form/form_data/answers.rb', line 27 def input_questions @input_questions end |
#parsed_questions ⇒ Arendelle (readonly)
An immutable object representing the question data from the form.
12 13 14 |
# File 'lib/typed_form/form_data/answers.rb', line 12 def parsed_questions @parsed_questions end |
#parsed_response ⇒ Arendelle (readonly)
An immutable object representing the submission data from the form.
12 13 14 |
# File 'lib/typed_form/form_data/answers.rb', line 12 def parsed_response @parsed_response end |
Class Method Details
.collate(parsed_response:, parsed_questions:, input_questions:) ⇒ Array<Question>
Builds a collection of Questions, with text extrapolated to support "piped" questions (i.e. "What is the name of your {answer_42}").
34 35 36 37 38 |
# File 'lib/typed_form/form_data/answers.rb', line 34 def self.collate(parsed_response:, parsed_questions:, input_questions:) new(parsed_response: parsed_response, parsed_questions: parsed_questions, input_questions: input_questions).questions end |
Instance Method Details
#answers ⇒ Arendelle
Returns Parsed Questions from Typeform Data API JSON.
21 |
# File 'lib/typed_form/form_data/answers.rb', line 21 def_delegators :parsed_response, :answers, :metadata, :token |
#metadata ⇒ Arendelle
Returns Parsed Metadata from Typeform Data API JSON.
21 |
# File 'lib/typed_form/form_data/answers.rb', line 21 def_delegators :parsed_response, :answers, :metadata, :token |
#questions ⇒ Array<Question>
Iterates through the existing collection of input questions to build a set of question value objects. Memoizes result.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/typed_form/form_data/answers.rb', line 43 def questions @_questions ||= input_questions.map do |question| text_answers = answers_for(question.ids) Question.with_response_data( question: question, answer: typecast_answer(answer: text_answers, type: question.type), text: extrapolated_question_text(question), original_answer: text_answers ) end end |
#token ⇒ String
Returns date form was submitted, in UTC.
21 |
# File 'lib/typed_form/form_data/answers.rb', line 21 def_delegators :parsed_response, :answers, :metadata, :token |