Class: LilUtils::CLI::YesNo
- Inherits:
-
OptionList
- Object
- OptionList
- LilUtils::CLI::YesNo
- Defined in:
- lib/lilutils/cli/cli.rb
Overview
A class that models the simple yes/no interaction with user on command line. Provides several ways to customize. @example: … Do you want to proceed [Y/n]? y (Enter) A simple Enter or ‘y’ returns the YES object. Pressing n returns NO object. Pressing anything else returns a value that depends on the mode which can be strict. If the mode is strict, it keeps on asking the user till s/he presses the correct key. If the mode is not strict, any invalid key (other than y, n, or enter) results in whatever the default option is. Note that the default option is shown as upper case key.
Constant Summary
Constants inherited from OptionList
Instance Method Summary collapse
-
#initialize(default_option = YES, prompt = DEFAULT_PROMPT, strict = true, istream = $stdin, ostream = $stdout) ⇒ YesNo
constructor
Creates a YesNo interaction.
Methods inherited from OptionList
#debug, #display_string, #show, #valid_response?
Constructor Details
#initialize(default_option = YES, prompt = DEFAULT_PROMPT, strict = true, istream = $stdin, ostream = $stdout) ⇒ YesNo
Creates a YesNo interaction.
197 198 199 |
# File 'lib/lilutils/cli/cli.rb', line 197 def initialize(default_option=YES, prompt=DEFAULT_PROMPT, strict=true, istream=$stdin, ostream=$stdout) super(YN, YN.index(default_option), prompt, strict, istream, ostream) end |