Module: Dsu::Support::Ask
- Included in:
- Dsu::Subcommands::BaseSubcommand, Views::Export, Views::Import, Views::Project::Create, Views::Project::Delete, Views::Project::Rename, Views::Project::Use
- Defined in:
- lib/dsu/support/ask.rb
Instance Method Summary collapse
-
#ask_while(prompt, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #yes?(prompt, options: {}) ⇒ Boolean
Instance Method Details
#ask_while(prompt, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dsu/support/ask.rb', line 9 def ask_while(prompt, options: {}) # rubocop:disable Lint/UnusedMethodArgument loop do print prompt char = $stdin.getch puts char return char if yield(char) char end end |
#yes?(prompt, options: {}) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dsu/support/ask.rb', line 20 def yes?(prompt, options: {}) auto_prompt = auto_prompt(prompt, ) unless auto_prompt.nil? puts prompt return auto_prompt end Thor::Base.shell.new.yes?(prompt) end |