Class: OllamaChat::Switches::Switch
- Inherits:
-
Object
- Object
- OllamaChat::Switches::Switch
- Includes:
- CheckSwitch
- Defined in:
- lib/ollama_chat/switches.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, msg:, config:) ⇒ Switch
constructor
A new instance of Switch.
- #set(value, show: false) ⇒ Object
- #toggle(show: true) ⇒ Object
Methods included from CheckSwitch
Constructor Details
#initialize(name, msg:, config:) ⇒ Switch
Returns a new instance of Switch.
19 20 21 22 |
# File 'lib/ollama_chat/switches.rb', line 19 def initialize(name, msg:, config:) @value = [ false, true ].include?(config) ? config : !!config.send("#{name}?") @msg = msg end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
24 25 26 |
# File 'lib/ollama_chat/switches.rb', line 24 def value @value end |
Instance Method Details
#set(value, show: false) ⇒ Object
26 27 28 29 |
# File 'lib/ollama_chat/switches.rb', line 26 def set(value, show: false) @value = !!value show && self.show end |
#toggle(show: true) ⇒ Object
31 32 33 34 |
# File 'lib/ollama_chat/switches.rb', line 31 def toggle(show: true) @value = !@value show && self.show end |