Class: Dev::UI::InteractivePrompt
- Inherits:
-
Object
- Object
- Dev::UI::InteractivePrompt
- Defined in:
- lib/dev/ui/interactive_prompt.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options) ⇒ InteractivePrompt
constructor
A new instance of InteractivePrompt.
Constructor Details
#initialize(options) ⇒ InteractivePrompt
Returns a new instance of InteractivePrompt.
11 12 13 14 15 16 |
# File 'lib/dev/ui/interactive_prompt.rb', line 11 def initialize() @options = @active = 1 @marker = '>' @answer = nil end |
Class Method Details
.call(options) ⇒ Object
6 7 8 9 |
# File 'lib/dev/ui/interactive_prompt.rb', line 6 def self.call() list = new() [list.call - 1] end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dev/ui/interactive_prompt.rb', line 18 def call Dev::UI.raw { print(ANSI.hide_cursor) } while @answer.nil? wait_for_user_input # This will put us back at the beginning of the options # When we redraw the options, they will be overwritten Dev::UI.raw do @options.size.times { print(ANSI.previous_line) } print(ANSI.previous_line + ANSI.end_of_line + "\n") end end @answer ensure Dev::UI.raw do print(ANSI.show_cursor) puts(ANSI.previous_line + ANSI.end_of_line) end end |