Module: SwitchDb::Dialog
- Defined in:
- lib/switch_db/dialog.rb
Class Method Summary collapse
-
.question?(message) ⇒ Boolean
rubocop:disable Performance/RegexpMatch.
Class Method Details
.question?(message) ⇒ Boolean
rubocop:disable Performance/RegexpMatch
4 5 6 7 8 9 10 11 12 |
# File 'lib/switch_db/dialog.rb', line 4 def self.question?() loop do print( + ' 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 |