Class: VagrantWizard::Select
- Defined in:
- lib/vagrant-wizard/inputs/select.rb
Instance Attribute Summary
Attributes inherited from Input
#data, #output, #prompt, #silent
Instance Method Summary collapse
Methods inherited from Input
Constructor Details
This class inherits a constructor from VagrantWizard::Input
Instance Method Details
#processInput ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vagrant-wizard/inputs/select.rb', line 7 def processInput prompt = TTY::Prompt.new choices = Hash.new @data['choices'].each do |choice| choices[choice['name']] = choice['value'] end if @data.key?('default') default_index = choices.find_index do |key,value| value == @data['default'] end default_index += 1 @output = prompt.select(@prompt) do || .default default_index choices.each do |key,value| .choice key,value end end return end @output = prompt.select(@prompt, choices) end |