Class: OllamaAgent::RuntimeCommandSystem::InteractiveMenu

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeInteractiveMenu

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

#indexObject (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

#suggestionsObject (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

#hideObject



21
22
23
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 21

def hide
  @visible = false
end

#nextObject



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

#previousObject



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

#selectedObject



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

Returns:

  • (Boolean)


25
26
27
# File 'lib/ollama_agent/runtime_command_system/interactive_menu.rb', line 25

def visible?
  @visible
end