Module: Starter::Prompt
Instance Method Summary collapse
Instance Method Details
#confirm(string) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/starter/prompt.rb', line 17 def confirm(string) print "#{string} [y/N] " if STDIN.gets.chomp =~ /^y/i yield if block_given? return true end end |
#prompt(string) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/starter/prompt.rb', line 6 def prompt(string) print "#{string} " value = STDIN.gets.chomp if value.size > 1 return value else puts "No, I really need a value. Try again." prompt(string) end end |