Class: OllamaChat::Switches::CombinedSwitch

Inherits:
Object
  • Object
show all
Includes:
CheckSwitch
Defined in:
lib/ollama_chat/switches.rb

Overview

Manages a boolean state based on a dynamic proc evaluation.

The CombinedSwitch class is useful for complex conditions that depend on multiple factors or dynamic values, such as combining multiple switch states into a single effective state.

Examples:

Checking if embedding is currently performed

# When embedding_enabled is true and embedding_paused is false,
# the combined switch will return true
combined_switch.value # => true

Instance Method Summary collapse

Methods included from CheckSwitch

#off?, #show

Constructor Details

#initialize(value:, msg:) ⇒ CombinedSwitch

Initializes a new CombinedSwitch instance.

Parameters:

  • value (Proc)

    the proc used to determine the current state

  • msg (Hash{Boolean => String})

    the message hash containing true and false keys



163
164
165
166
# File 'lib/ollama_chat/switches.rb', line 163

def initialize(value:, msg:)
  @value = value
  @msg   = msg
end

Instance Method Details

#valueBoolean

Returns the result of calling the stored proc.

Returns:

  • (Boolean)

    the result of the dynamic evaluation



171
172
173
# File 'lib/ollama_chat/switches.rb', line 171

def value
  @value.()
end