Class: QuestionproRails::ResponseSet
- Inherits:
-
Object
- Object
- QuestionproRails::ResponseSet
- Defined in:
- lib/questionpro_rails/response_set.rb
Instance Attribute Summary collapse
-
#qp_values ⇒ Array<Hash>
readonly
Answers collected from the survey response.
-
#question_code ⇒ Object
readonly
Returns the value of attribute question_code.
-
#question_description ⇒ Object
readonly
Returns the value of attribute question_description.
-
#question_id ⇒ Object
readonly
Returns the value of attribute question_id.
-
#question_text ⇒ Object
readonly
Returns the value of attribute question_text.
Instance Method Summary collapse
-
#answers ⇒ Array<QuestionproRails::ResponseAnswer>
Extract the Answers from the hashes stored inside qp_values attribute.
-
#initialize(attributes) ⇒ ResponseSet
constructor
A new instance of ResponseSet.
Constructor Details
#initialize(attributes) ⇒ ResponseSet
Returns a new instance of ResponseSet.
11 12 13 14 15 16 17 |
# File 'lib/questionpro_rails/response_set.rb', line 11 def initialize (attributes) @question_code = attributes['questionCode'] @question_description = attributes['questionDescription'] @question_id = attributes['questionID'] @question_text = attributes['questionText'] @qp_values = attributes['values'] end |
Instance Attribute Details
#qp_values ⇒ Array<Hash> (readonly)
Returns Answers collected from the survey response.
9 10 11 |
# File 'lib/questionpro_rails/response_set.rb', line 9 def qp_values @qp_values end |
#question_code ⇒ Object (readonly)
Returns the value of attribute question_code.
6 7 8 |
# File 'lib/questionpro_rails/response_set.rb', line 6 def question_code @question_code end |
#question_description ⇒ Object (readonly)
Returns the value of attribute question_description.
6 7 8 |
# File 'lib/questionpro_rails/response_set.rb', line 6 def question_description @question_description end |
#question_id ⇒ Object (readonly)
Returns the value of attribute question_id.
6 7 8 |
# File 'lib/questionpro_rails/response_set.rb', line 6 def question_id @question_id end |
#question_text ⇒ Object (readonly)
Returns the value of attribute question_text.
6 7 8 |
# File 'lib/questionpro_rails/response_set.rb', line 6 def question_text @question_text end |
Instance Method Details
#answers ⇒ Array<QuestionproRails::ResponseAnswer>
Extract the Answers from the hashes stored inside qp_values attribute.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/questionpro_rails/response_set.rb', line 23 def answers extracted_answers = [] unless self.qp_values.nil? self.qp_values.each do |answer| extracted_answers.push(ResponseAnswer.new(answer)) end end return extracted_answers end |