Class: Invoker::CLI::Question

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/cli/question.rb

Class Method Summary collapse

Class Method Details

.agree(question_text) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/invoker/cli/question.rb', line 3

def self.agree(question_text)
  $stdout.print(question_text)
  answer = $stdin.gets
  answer.strip!
  if answer =~ /\Ay(?:es)?|no?\Z/i
    answer =~ /\Ay(?:es)?\Z/i
  else
    $stdout.puts "Please enter 'yes' or 'no'."
    agree(question_text)
  end
end