Class: QuestionproRails::Section
- Inherits:
-
Object
- Object
- QuestionproRails::Section
- Defined in:
- lib/questionpro_rails/section.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#dynamic_explode_text ⇒ Object
readonly
Returns the value of attribute dynamic_explode_text.
-
#exact_min_answers ⇒ Object
readonly
Returns the value of attribute exact_min_answers.
-
#has_page_break ⇒ Object
readonly
Returns the value of attribute has_page_break.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#left_anchor ⇒ Object
readonly
Returns the value of attribute left_anchor.
-
#max_answers ⇒ Object
readonly
Returns the value of attribute max_answers.
-
#min_answers ⇒ Object
readonly
Returns the value of attribute min_answers.
-
#mobile_friendly ⇒ Object
readonly
Returns the value of attribute mobile_friendly.
-
#num_tasks ⇒ Object
readonly
Returns the value of attribute num_tasks.
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
-
#qp_questions ⇒ Array<Hash>
readonly
Questions collected inside the section.
-
#random ⇒ Object
readonly
Returns the value of attribute random.
-
#random_section ⇒ Object
readonly
Returns the value of attribute random_section.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#right_anchor ⇒ Object
readonly
Returns the value of attribute right_anchor.
-
#subtype ⇒ Object
readonly
Returns the value of attribute subtype.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#video ⇒ Object
readonly
Returns the value of attribute video.
-
#video_type ⇒ Object
readonly
Returns the value of attribute video_type.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Section
constructor
A new instance of Section.
-
#questions ⇒ Array<QuestionproRails::Question>
Extract the Questions from the hashes stored inside qp_questions attribute.
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def code @code end |
#dynamic_explode_text ⇒ Object (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_answers ⇒ Object (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_break ⇒ Object (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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def id @id end |
#left_anchor ⇒ Object (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_answers ⇒ Object (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_answers ⇒ Object (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_friendly ⇒ Object (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_tasks ⇒ Object (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 |
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def orientation @orientation end |
#qp_questions ⇒ Array<Hash> (readonly)
Returns Questions collected inside the section.
13 14 15 |
# File 'lib/questionpro_rails/section.rb', line 13 def qp_questions @qp_questions end |
#random ⇒ Object (readonly)
Returns the value of attribute random.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def random @random end |
#random_section ⇒ Object (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 |
#required ⇒ Object (readonly)
Returns the value of attribute required.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def required @required end |
#right_anchor ⇒ Object (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 |
#subtype ⇒ Object (readonly)
Returns the value of attribute subtype.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def subtype @subtype end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def type @type end |
#video ⇒ Object (readonly)
Returns the value of attribute video.
6 7 8 |
# File 'lib/questionpro_rails/section.rb', line 6 def video @video end |
#video_type ⇒ Object (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
#questions ⇒ Array<QuestionproRails::Question>
Extract the Questions from the hashes stored inside qp_questions attribute.
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 |