Class: LLM::Repl::Input::Cache Private

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/repl/input/cache.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Tracks the state of the active completion so that repeated TAB presses can cycle through the candidate list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(candidates, index) ⇒ LLM::Repl::Input::Cache

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • candidates (Array<String>)
  • index (Integer)


13
14
15
16
# File 'lib/llm/repl/input/cache.rb', line 13

def initialize(candidates, index)
  @candidates = candidates
  @index = index
end

Instance Attribute Details

#candidatesArray<String> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<String>)


20
21
22
# File 'lib/llm/repl/input/cache.rb', line 20

def candidates
  @candidates
end

#indexInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


24
25
26
# File 'lib/llm/repl/input/cache.rb', line 24

def index
  @index
end

Instance Method Details

#include?(str) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


41
42
43
# File 'lib/llm/repl/input/cache.rb', line 41

def include?(str)
  @candidates.include?(str)
end

#next_indexInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the next index, wrapping around the list.

Returns:

  • (Integer)


29
30
31
# File 'lib/llm/repl/input/cache.rb', line 29

def next_index
  (@index + 1) % @candidates.size
end

#valueString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


35
36
37
# File 'lib/llm/repl/input/cache.rb', line 35

def value
  @candidates[@index]
end