Class: RailsInteractive::CLI::Prompt
- Inherits:
-
Object
- Object
- RailsInteractive::CLI::Prompt
- Defined in:
- lib/cli/prompt.rb
Overview
Prompt class for commands
Instance Method Summary collapse
-
#initialize(msg, type, options = nil, required: false) ⇒ Interactive::Prompt
constructor
Create a new instance.
-
#perform ⇒ String
Perform the prompt.
Constructor Details
#initialize(msg, type, options = nil, required: false) ⇒ Interactive::Prompt
Create a new instance
17 18 19 20 21 22 23 |
# File 'lib/cli/prompt.rb', line 17 def initialize(msg, type, = nil, required: false) @msg = msg @type = type @options = @required = required @prompt = TTY::Prompt.new end |
Instance Method Details
#perform ⇒ String
Perform the prompt
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cli/prompt.rb', line 28 def perform case @type when "ask" @prompt.ask(@msg, required: @required) when "select" @prompt.select(@msg, @options, required: @required) when "multi_select" @prompt.multi_select(@msg, @options) else puts "Invalid parameter" end end |