module SwitchDb::Dialog
Public Class Methods
question?(message)
click to toggle source
rubocop:disable Performance/RegexpMatch
# File lib/switch_db/dialog.rb, line 4 def self.question?(message) loop do print(message + ' y/n ') answer = $stdin.gets.strip return true if /\A(?:y|yes)\z/i =~ answer return false if /\A(?:n|no)\z/i =~ answer end end