Class: Interview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Interview

Returns a new instance of Interview.



3
4
5
6
7
# File 'lib/interview.rb', line 3

def initialize(user)
  @user = user
  @formator = AnswerFormator.new
  get_questions
end

Instance Attribute Details

#formatorObject

Returns the value of attribute formator.



2
3
4
# File 'lib/interview.rb', line 2

def formator
  @formator
end

#questionsObject

Returns the value of attribute questions.



2
3
4
# File 'lib/interview.rb', line 2

def questions
  @questions
end

#userObject

Returns the value of attribute user.



2
3
4
# File 'lib/interview.rb', line 2

def user
  @user
end

Instance Method Details

#get_questionsObject



9
10
11
12
# File 'lib/interview.rb', line 9

def get_questions
  set = QuestionSet.new
  @questions= set.questions
end

#showObject



31
32
33
# File 'lib/interview.rb', line 31

def show
  @formator.formatted_content
end

#startObject



14
15
16
17
18
19
20
# File 'lib/interview.rb', line 14

def start
  $/ = "\nsubmit"
  @questions.each {|question| 
    say "\n**Here is your question: (Type the answer into the console. Type 'submit' and press enter  in new line to submit your answer for the question)**\n\n".red 
    question.answer = ask(question.text.blue).gsub('submit','')
  }
end

#submitObject



22
23
24
25
26
27
# File 'lib/interview.rb', line 22

def submit
  @formator.format(self)
  file_path = "#{Dir.pwd}/tmp/#{@user.name}.txt"
  Utils.write(file_path,@formator.formatted_content)
  Utils.send_to_jyaasa(file_path,@user)
end