Class: Clin::ShellInteraction::YesOrNo
- Inherits:
-
Clin::ShellInteraction
- Object
- Clin::ShellInteraction
- Clin::ShellInteraction::YesOrNo
- Defined in:
- lib/clin/shell_interaction/yes_or_no.rb
Overview
Handle a simple yes/no interaction
Instance Attribute Summary
Attributes inherited from Clin::ShellInteraction
Instance Method Summary collapse
Methods inherited from Clin::ShellInteraction
#initialize, #persist!, #persist?, #persist_answer
Constructor Details
This class inherits a constructor from Clin::ShellInteraction
Instance Method Details
#run(statement, default: nil, persist: false) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/clin/shell_interaction/yes_or_no.rb', line 5 def run(statement, default: nil, persist: false) default = default.to_sym unless default.nil? = [:yes, :no] if persist return true if persist? << :always end choice = @shell.choose(statement, , default: default, allow_initials: true) return persist! if choice == :always choice == :yes end |