Class: QuestionproRails::ResponseSet

Inherits:
Object
  • Object
show all
Defined in:
lib/questionpro_rails/response_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_valuesArray<Hash> (readonly)

Returns Answers collected from the survey response.

Returns:

  • (Array<Hash>)

    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_codeObject (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_descriptionObject (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_idObject (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_textObject (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

#answersArray<QuestionproRails::ResponseAnswer>

Extract the Answers from the hashes stored inside qp_values attribute.

Returns:



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