Class: QuestionproRails::Survey

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Survey

Returns a new instance of Survey.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/questionpro_rails/survey.rb', line 12

def initialize (attributes)
  @id                = (attributes['id'] || attributes['surveyID']) 
  @name              = (attributes['title'] || attributes['surveyName'])
  @url               = (attributes['surveyURL'] || attributes['connectURL'])
  @subtitle          = attributes['subtitle']
  @thank_you_message = attributes['thankYouMessage']
  @has_scoring_logic = attributes['hasScoringLogic']
  @numeric_title     = attributes['numericTitle']
  @status            = attributes['status']
  @qp_sections       = attributes['sections']
end

Instance Attribute Details

#has_scoring_logicObject (readonly)

Returns the value of attribute has_scoring_logic.



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

def has_scoring_logic
  @has_scoring_logic
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#numeric_titleObject (readonly)

Returns the value of attribute numeric_title.



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

def numeric_title
  @numeric_title
end

#qp_sectionsArray<Hash> (readonly)

Returns Sections collected from the survey request.

Returns:

  • (Array<Hash>)

    Sections collected from the survey request.



10
11
12
# File 'lib/questionpro_rails/survey.rb', line 10

def qp_sections
  @qp_sections
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#subtitleObject (readonly)

Returns the value of attribute subtitle.



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

def subtitle
  @subtitle
end

#thank_you_messageObject (readonly)

Returns the value of attribute thank_you_message.



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

def thank_you_message
  @thank_you_message
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#sectionsArray<QuestionproRails::Section>

Extract the Sections from the hashes stored inside qp_sections attribute.

Returns:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/questionpro_rails/survey.rb', line 28

def sections
  extracted_sections = []

  unless self.qp_sections.nil?
    self.qp_sections.each do |section|   
      extracted_sections.push(Section.new(section))
    end           
  end

  return extracted_sections
end