Class: Prompts::ConfirmPrompt
- Defined in:
- lib/prompts/confirm_prompt.rb
Instance Method Summary collapse
-
#initialize ⇒ ConfirmPrompt
constructor
A new instance of ConfirmPrompt.
Methods inherited from Prompt
ask, #ask, #content, #default, #hint, #label, #prepare_content, #prepend_content
Constructor Details
#initialize ⇒ ConfirmPrompt
Returns a new instance of ConfirmPrompt.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/prompts/confirm_prompt.rb', line 5 def initialize(...) super @prompt = if @default == false "Choose [y/N]:" elsif @default == true "Choose [Y/n]:" else "Choose [y/n]:" end @default_boolean = @default @default = nil @instructions = "Press Enter to submit" @validations << ->(choice) { "Invalid choice." if !["y", "n", "Y", "N", ""].include?(choice) } end |