Class: OllamaAgent::RuntimeCommandSystem::InteractiveMenu
- Inherits:
-
Object
- Object
- OllamaAgent::RuntimeCommandSystem::InteractiveMenu
- Defined in:
- lib/ollama_agent/runtime_command_system/interactive_menu.rb
Overview
State holder for dropdown selection. Rendering is owned by the TUI layer.
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
Instance Method Summary collapse
- #hide ⇒ Object
-
#initialize ⇒ InteractiveMenu
constructor
A new instance of InteractiveMenu.
- #next ⇒ Object
- #previous ⇒ Object
- #selected ⇒ Object
- #show(suggestions) ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize ⇒ InteractiveMenu
Returns a new instance of InteractiveMenu.
9 10 11 12 13 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 9 def initialize @visible = false @suggestions = [] @index = 0 end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 7 def index @index end |
#suggestions ⇒ Object (readonly)
Returns the value of attribute suggestions.
7 8 9 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 7 def suggestions @suggestions end |
Instance Method Details
#hide ⇒ Object
21 22 23 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 21 def hide @visible = false end |
#next ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 29 def next return nil if @suggestions.empty? @index = (@index + 1) % @suggestions.length selected end |
#previous ⇒ Object
36 37 38 39 40 41 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 36 def previous return nil if @suggestions.empty? @index = (@index - 1) % @suggestions.length selected end |
#selected ⇒ Object
43 44 45 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 43 def selected @suggestions[@index] end |
#show(suggestions) ⇒ Object
15 16 17 18 19 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 15 def show(suggestions) @suggestions = Array(suggestions) @index = 0 @visible = @suggestions.any? end |
#visible? ⇒ Boolean
25 26 27 |
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 25 def visible? @visible end |