Class: QuestionproRails::SurveyMeta

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ SurveyMeta

Returns a new instance of SurveyMeta.



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

def initialize (attributes)
  @email_groups_list = attributes['emailGroups']
  @templates_list    = attributes['templates']
end

Instance Attribute Details

#email_groups_listArray<Hash> (readonly)

Returns Email Groups List collected from the survey meta.

Returns:

  • (Array<Hash>)

    Email Groups List collected from the survey meta.



8
9
10
# File 'lib/questionpro_rails/survey_meta.rb', line 8

def email_groups_list
  @email_groups_list
end

#templates_listArray<Hash> (readonly)

Returns Templates List collected from the survey meta.

Returns:

  • (Array<Hash>)

    Templates List collected from the survey meta.



11
12
13
# File 'lib/questionpro_rails/survey_meta.rb', line 11

def templates_list
  @templates_list
end

Instance Method Details

#email_groupsArray<QuestionproRails::EmailGroup>

Extract the Email Groups from the hashes stored inside email_groups_list attribute.

Returns:



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/questionpro_rails/survey_meta.rb', line 22

def email_groups
  extracted_groups = []

  unless self.email_groups_list.nil? 
    self.email_groups_list.each do |email_group|
      extracted_groups.push(EmailGroup.new(email_group))
    end
  end

  return extracted_groups
end

#templatesArray<QuestionproRails::Template>

Extract the Templates from the hashes stored inside templates_list attribute.

Returns:



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/questionpro_rails/survey_meta.rb', line 38

def templates
  extracted_templates = []

  unless self.templates_list.nil? 
    self.templates_list.each do |template|
      extracted_templates.push(Template.new(template))
    end
  end

  return extracted_templates      
end