Class: Surveymonkey::Response::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/surveymonkey_api/response/page.rb

Overview

Response Page

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data, page_structure) ⇒ Page

Returns a new instance of Page.



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

def initialize(raw_data, page_structure)
  @raw_data = raw_data
  @id = raw_data['id']
  @page_structure = page_structure
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#page_structureObject (readonly)

Returns the value of attribute page_structure.



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

def page_structure
  @page_structure
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



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

def raw_data
  @raw_data
end

Instance Method Details

#questionsObject



17
18
19
20
21
22
# File 'lib/surveymonkey_api/response/page.rb', line 17

def questions
  @questions ||= raw_data['questions'].each_with_object([]) do |question, arr|
    question_structure = page_structure['questions'].detect { |q| q['id'] == question['id'] }
    arr << Surveymonkey::Response::Question.new(question, question_structure)
  end
end

#titleObject

Match page title



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

def title
  @title ||= page_structure['title']
end