Class: QuestionproRails::SurveyResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ SurveyResponse

Returns a new instance of SurveyResponse.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/questionpro_rails/survey_response.rb', line 13

def initialize (attributes)
  @id                 = attributes['id']
  @country            = attributes['country']
  @duplicate          = attributes['duplicate']
  @external_reference = attributes['externalReference']
  @ip_address         = attributes['ipAddress']
  @region             = attributes['region']
  @qp_response_set    = attributes['responseSet']
  @response_status    = attributes['responseStatus']
  @time_taken         = attributes['timeTaken']
  @timestamp          = attributes['timestamp']
  @original_object    = attributes
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def country
  @country
end

#duplicateObject (readonly)

Returns the value of attribute duplicate.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def duplicate
  @duplicate
end

#external_referenceObject (readonly)

Returns the value of attribute external_reference.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def external_reference
  @external_reference
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def id
  @id
end

#ip_addressObject (readonly)

Returns the value of attribute ip_address.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def ip_address
  @ip_address
end

#original_objectObject (readonly)

Returns the value of attribute original_object.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def original_object
  @original_object
end

#qp_response_setArray<Hash> (readonly)

Returns Response Set collected from the survey response.

Returns:

  • (Array<Hash>)

    Response Set collected from the survey response.



11
12
13
# File 'lib/questionpro_rails/survey_response.rb', line 11

def qp_response_set
  @qp_response_set
end

#regionObject (readonly)

Returns the value of attribute region.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def region
  @region
end

#response_statusObject (readonly)

Returns the value of attribute response_status.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def response_status
  @response_status
end

#time_takenObject (readonly)

Returns the value of attribute time_taken.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def time_taken
  @time_taken
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/questionpro_rails/survey_response.rb', line 6

def timestamp
  @timestamp
end

Instance Method Details

#response_setArray<QuestionproRails::ResponseSet>

Extract the Response Set from the hash stored inside qp_response_set attribute.

Returns:



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/questionpro_rails/survey_response.rb', line 31

def response_set
  extracted_sets = []

  unless self.qp_response_set.nil?
    self.qp_response_set.each do |set|   
      extracted_sets.push(ResponseSet.new(set))
    end           
  end

  return extracted_sets
end