Module: AIA::UserQuery

Included in:
Main, Prompt
Defined in:
lib/aia/user_query.rb

Instance Method Summary collapse

Instance Method Details

#ask_question_with_reline(prompt) ⇒ Object

Function to prompt the user with a question using reline



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/aia/user_query.rb', line 8

def ask_question_with_reline(prompt)
  if prompt.start_with?("\n")
    puts
    puts
    prompt = prompt[1..]
  end

  answer = Reline.readline(prompt)
  Reline::HISTORY.push(answer) unless answer.nil? || Reline::HISTORY.to_a.include?(answer)
  answer
  rescue Interrupt
    ''
end