Class: Surveymonkey::Response::Question
- Inherits:
-
Object
- Object
- Surveymonkey::Response::Question
- Defined in:
- lib/surveymonkey_api/response/question.rb
Overview
Response Question
Defined Under Namespace
Classes: Answer
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#question_structure ⇒ Object
readonly
Returns the value of attribute question_structure.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
- #answers ⇒ Object
-
#initialize(raw_data, question_structure) ⇒ Question
constructor
A new instance of Question.
-
#title ⇒ Object
Match response title.
Constructor Details
#initialize(raw_data, question_structure) ⇒ Question
Returns a new instance of Question.
6 7 8 9 10 |
# File 'lib/surveymonkey_api/response/question.rb', line 6 def initialize(raw_data, question_structure) @raw_data = raw_data @id = raw_data['id'] @question_structure = question_structure end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/surveymonkey_api/response/question.rb', line 4 def id @id end |
#question_structure ⇒ Object (readonly)
Returns the value of attribute question_structure.
4 5 6 |
# File 'lib/surveymonkey_api/response/question.rb', line 4 def question_structure @question_structure end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
4 5 6 |
# File 'lib/surveymonkey_api/response/question.rb', line 4 def raw_data @raw_data end |
Instance Method Details
#answers ⇒ Object
17 18 19 20 21 22 |
# File 'lib/surveymonkey_api/response/question.rb', line 17 def answers @answers ||= raw_data['answers'].each_with_object([]) do |answer, arr| answer_structure = question_structure['answers'] arr << Surveymonkey::Response::Question::Answer.new(answer, answer_structure) end end |
#title ⇒ Object
Match response title
13 14 15 |
# File 'lib/surveymonkey_api/response/question.rb', line 13 def title @title ||= question_structure['headings'].first['heading'] end |