Class: Prompts::ConfirmPrompt

Inherits:
Prompt
  • Object
show all
Defined in:
lib/prompts/confirm_prompt.rb

Instance Method Summary collapse

Methods inherited from Prompt

ask, #ask, #content, #default, #hint, #label, #prepare_content, #prepend_content

Constructor Details

#initializeConfirmPrompt

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