Module: Ollama::Handlers::Concern
- Extended by:
- Tins::Concern, Tins::Implement
- Defined in:
- lib/ollama/handlers/concern.rb
Overview
A module that defines the common interface and behavior for all response handlers used with Ollama client commands.
Handlers are responsible for processing responses from the Ollama API according to specific logic, such as printing output, collecting results, or displaying progress. This module establishes the foundational structure that all handler classes must implement to be compatible with the client’s command execution flow.
Instance Attribute Summary collapse
-
#output ⇒ IO
readonly
The output attribute reader returns the output stream used by the client.
-
#result ⇒ Object
The result attribute allows reading and setting the final outcome of a command operation.
Instance Method Summary collapse
-
#initialize(output: $stdout) ⇒ Object
The initialize method sets up a new handler instance with the specified output destination.
-
#to_proc ⇒ Proc
The to_proc method converts the handler instance into a proc object.
Instance Attribute Details
#output ⇒ IO (readonly)
The output attribute reader returns the output stream used by the client.
28 29 30 |
# File 'lib/ollama/handlers/concern.rb', line 28 def output @output end |
#result ⇒ Object
The result attribute allows reading and setting the final outcome of a command operation.
34 35 36 |
# File 'lib/ollama/handlers/concern.rb', line 34 def result @result end |
Instance Method Details
#initialize(output: $stdout) ⇒ Object
The initialize method sets up a new handler instance with the specified output destination.
20 21 22 |
# File 'lib/ollama/handlers/concern.rb', line 20 def initialize(output: $stdout) @output = output end |
#to_proc ⇒ Proc
The to_proc method converts the handler instance into a proc object.
This method returns a lambda that takes a response parameter and calls the handler’s call method with that response, enabling the handler to be used in contexts where a proc is expected.
55 56 57 |
# File 'lib/ollama/handlers/concern.rb', line 55 def to_proc -> response { call(response) } end |