Class: Cb::CbApplication

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/models/cb_application.rb

Defined Under Namespace

Classes: CbAnswer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_did, site_id = '', co_brand = '', resume_file_name = '', resume = nil, test = false) ⇒ CbApplication

Returns a new instance of CbApplication.



7
8
9
10
11
12
13
14
15
# File 'lib/cb/models/cb_application.rb', line 7

def initialize(job_did, site_id = '', co_brand = '', resume_file_name = '', resume = nil, test = false)
  @job_did          = job_did
  @site_id          = site_id
  @co_brand         = co_brand
  @test             = test
  @resume_file_name = resume_file_name
  @resume           = resume
  @answers          = []
end

Instance Attribute Details

#answers ⇒ Object

Returns the value of attribute answers.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def answers
  @answers
end

#co_brand ⇒ Object

Returns the value of attribute co_brand.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def co_brand
  @co_brand
end

#job_did ⇒ Object

Returns the value of attribute job_did.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def job_did
  @job_did
end

#resume_file ⇒ Object

Returns the value of attribute resume_file.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def resume_file
  @resume_file
end

#resume_file_name ⇒ Object

Returns the value of attribute resume_file_name.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def resume_file_name
  @resume_file_name
end

#site_id ⇒ Object

Returns the value of attribute site_id.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def site_id
  @site_id
end

#test ⇒ Object

Returns the value of attribute test.



3
4
5
# File 'lib/cb/models/cb_application.rb', line 3

def test
  @test
end

Instance Method Details

#add_answer(id, text) ⇒ Object



17
18
19
# File 'lib/cb/models/cb_application.rb', line 17

def add_answer(id, text)
  @answers << CbApplication::CbAnswer.new(id, text)
end

#to_xml ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cb/models/cb_application.rb', line 21

def to_xml
  ret = '<RequestApplication>'

  ret = "#{ret}<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>"
  ret = "#{ret}<JobDID>#{@job_did}</JobDID>"
  ret = "#{ret}<Test>#{@test}</Test>"
  ret = "#{ret}<SiteID>#{@site_id}</SiteID>"
  ret = "#{ret}<CoBrand>#{@co_brand}</CoBrand>"
  ret = "#{ret}<Resume><ResumeFileName>#{@resume_file_name}</ResumeFileName><ResumeData>#{@resume}</ResumeData></Resume>" unless @resume.nil?

  unless @answers.count == 0
    ret = "#{ret}<Responses>"
    @answers.each do | ans |
      ret = "#{ret}#{ans.to_xml}"
    end
    ret = "#{ret}</Responses>"
  end

  "#{ret}</RequestApplication>"
end