Sha256: 047339d7a54974879695b20f6bd406e1aa0f1fa1c99f03a4bb61ffdb55f73be9
Contents?: true
Size: 699 Bytes
Versions: 1
Compression:
Stored size: 699 Bytes
Contents
# frozen_string_literal: true module Prompts class ConfirmPrompt < Prompt 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 private def resolve_choice_from(response) case response when "y", "Y" then true when "n", "N" then false when "" then @default_boolean end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prompts-0.2.0 | lib/prompts/confirm_prompt.rb |