Module: OllamaChat::Switches::CheckSwitch

Extended by:
Tins::Concern
Included in:
CombinedSwitch, DatabaseSwitch, Switch
Defined in:
lib/ollama_chat/switches.rb

Overview

A module that provides switch state checking functionality.

The CheckSwitch module adds methods for checking the boolean state of switches and displaying their current status. It's designed to be included in switch classes to provide consistent behavior for querying switch states and outputting status messages.

Examples:

Checking switch states

switch = OllamaChat::Switches::Switch.new(value: true, msg: { true => 'On', false => 'Off' })
switch.on?   # Returns true
switch.off?  # Returns false

Instance Method Summary collapse

Instance Method Details

#off?Boolean

Returns true if the switch is in the off state, false otherwise.

Returns:

  • (Boolean)

    indicating whether the switch is off



36
37
38
# File 'lib/ollama_chat/switches.rb', line 36

def off?
  !on?
end

#show(output: STDOUT) ⇒ Object

Displays the message associated with the current switch state.

Parameters:

  • output (IO) (defaults to: STDOUT)

    the output stream to write the message to



43
44
45
# File 'lib/ollama_chat/switches.rb', line 43

def show(output: STDOUT)
  output.puts @msg[value]
end