Class: Surveymonkey::Response

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/surveymonkey_api/response.rb

Overview

Response

Defined Under Namespace

Classes: Page, Question

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(survey_id, id) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
# File 'lib/surveymonkey_api/response.rb', line 7

def initialize(survey_id, id)
  @survey_id = survey_id
  @id = id
  @survey_structure = Surveymonkey::Survey.new(survey_id)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/surveymonkey_api/response.rb', line 5

def id
  @id
end

#survey_idObject (readonly)

Returns the value of attribute survey_id.



5
6
7
# File 'lib/surveymonkey_api/response.rb', line 5

def survey_id
  @survey_id
end

#survey_structureObject (readonly)

Returns the value of attribute survey_structure.



5
6
7
# File 'lib/surveymonkey_api/response.rb', line 5

def survey_structure
  @survey_structure
end

Instance Method Details

#infoObject



17
18
19
# File 'lib/surveymonkey_api/response.rb', line 17

def info
  raw_details.dup.tap { |h| h.delete('pages') }
end

#pages(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/surveymonkey_api/response.rb', line 21

def pages(options = {})
  @pages ||= raw_details(options)['pages'].each_with_object([]) do |page, arr|
    unless page['questions'].empty?
      page_structure = details['pages'].detect { |p| p['id'] == page['id'] }
      arr << Surveymonkey::Response::Page.new(page, page_structure)
    end
  end
end

#raw_details(options = {}) ⇒ Object



13
14
15
# File 'lib/surveymonkey_api/response.rb', line 13

def raw_details(options = {})
  @raw_details ||= client.survey_response(survey_id, id, options)
end