Class: VagrantWizard::PromptParser
- Inherits:
-
Object
- Object
- VagrantWizard::PromptParser
- Defined in:
- lib/vagrant-wizard/prompt-parser.rb
Instance Attribute Summary collapse
-
#advanced ⇒ Object
Returns the value of attribute advanced.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(prompt) ⇒ PromptParser
constructor
A new instance of PromptParser.
- #prompt ⇒ Object
Constructor Details
#initialize(prompt) ⇒ PromptParser
Returns a new instance of PromptParser.
6 7 8 9 10 11 |
# File 'lib/vagrant-wizard/prompt-parser.rb', line 6 def initialize(prompt) @prompt = prompt @advanced = false @key = @prompt['key'] @output = nil end |
Instance Attribute Details
#advanced ⇒ Object
Returns the value of attribute advanced.
4 5 6 |
# File 'lib/vagrant-wizard/prompt-parser.rb', line 4 def advanced @advanced end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/vagrant-wizard/prompt-parser.rb', line 3 def key @key end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
2 3 4 |
# File 'lib/vagrant-wizard/prompt-parser.rb', line 2 def output @output end |
Instance Method Details
#prompt ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-wizard/prompt-parser.rb', line 13 def prompt promptType = @prompt['type'] promptQuestion = @prompt['prompt'] begin require "vagrant-wizard/inputs/#{promptType}" rescue LoadError puts "Unable to process input type '#{promptType}'" if @prompt.key?('default') @output = @prompt['default'] end exit end className = Object.const_get("VagrantWizard::#{promptType.capitalize}") prompt = className.new(promptQuestion, @prompt) if @prompt.key?('advanced') && @advanced == false if @prompt['advanced'] == true prompt.silent = true end end @output = prompt.prompt() end |