Class: QuestionproRails::Section

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Section

Returns a new instance of Section.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/questionpro_rails/section.rb', line 15

def initialize(attributes)
    @id                   = attributes['sectionID']
    @title								= attributes['title']
	@num_tasks            = attributes['numTasks']
	@exact_min_answers    = attributes['exactMinAnswers']
	@orientation          = attributes['orientation']
	@code                 = attributes['code']
	@video_type           = attributes['videoType']
	@max_answers          = attributes['maxAnswers']			
	@dynamic_explode_text = attributes['dynamicExplodeText']			
	@video                = attributes['video']
	@type                 = attributes['type']
	@min_answers          = attributes['minAnswers']
	@required             = attributes['required']
	@has_page_break       = attributes['hasPageBreak']
	@random               = attributes['random']
	@random_section       = attributes['randomSection']
	@subtype              = attributes['subtype']
	@mobile_friendly      = attributes['mobileFriendly']	
	@qp_questions         = attributes['questions']	
	@right_anchor					= attributes['rightAnchor']
	@left_anchor				  = attributes['leftAnchor']			
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#dynamic_explode_textObject (readonly)

Returns the value of attribute dynamic_explode_text.



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

def dynamic_explode_text
  @dynamic_explode_text
end

#exact_min_answersObject (readonly)

Returns the value of attribute exact_min_answers.



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

def exact_min_answers
  @exact_min_answers
end

#has_page_breakObject (readonly)

Returns the value of attribute has_page_break.



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

def has_page_break
  @has_page_break
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#left_anchorObject (readonly)

Returns the value of attribute left_anchor.



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

def left_anchor
  @left_anchor
end

#max_answersObject (readonly)

Returns the value of attribute max_answers.



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

def max_answers
  @max_answers
end

#min_answersObject (readonly)

Returns the value of attribute min_answers.



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

def min_answers
  @min_answers
end

#mobile_friendlyObject (readonly)

Returns the value of attribute mobile_friendly.



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

def mobile_friendly
  @mobile_friendly
end

#num_tasksObject (readonly)

Returns the value of attribute num_tasks.



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

def num_tasks
  @num_tasks
end

#orientationObject (readonly)

Returns the value of attribute orientation.



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

def orientation
  @orientation
end

#qp_questionsArray<Hash> (readonly)

Returns Questions collected inside the section.

Returns:

  • (Array<Hash>)

    Questions collected inside the section.



13
14
15
# File 'lib/questionpro_rails/section.rb', line 13

def qp_questions
  @qp_questions
end

#randomObject (readonly)

Returns the value of attribute random.



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

def random
  @random
end

#random_sectionObject (readonly)

Returns the value of attribute random_section.



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

def random_section
  @random_section
end

#requiredObject (readonly)

Returns the value of attribute required.



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

def required
  @required
end

#right_anchorObject (readonly)

Returns the value of attribute right_anchor.



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

def right_anchor
  @right_anchor
end

#subtypeObject (readonly)

Returns the value of attribute subtype.



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

def subtype
  @subtype
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#videoObject (readonly)

Returns the value of attribute video.



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

def video
  @video
end

#video_typeObject (readonly)

Returns the value of attribute video_type.



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

def video_type
  @video_type
end

Instance Method Details

#questionsArray<QuestionproRails::Question>

Extract the Questions from the hashes stored inside qp_questions attribute.

Returns:



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/questionpro_rails/section.rb', line 43

def questions
    extracted_questions = []

    unless self.qp_questions.nil?
      self.qp_questions.each do |question|   
        extracted_questions.push(Question.new(question))
      end           
    end

    return extracted_questions			
end