Class: Ollama::Handlers::Collector
- Inherits:
-
Object
- Object
- Ollama::Handlers::Collector
- Includes:
- Concern
- Defined in:
- lib/ollama/handlers/collector.rb
Overview
A handler that collects responses into an array and returns the array as the result.
The Collector handler is designed to accumulate all responses during command execution and provide access to the complete collection of responses through its result method. It is typically used when multiple responses are expected and need to be processed together rather than individually.
Instance Attribute Summary
Attributes included from Concern
Instance Method Summary collapse
-
#call(response) ⇒ self
The call method processes a response by appending it to an internal array.
-
#initialize(output: $stdout) ⇒ Collector
constructor
The initialize method sets up a new handler instance with the specified output destination and initializes an empty array for collecting responses.
-
#result ⇒ Array<Ollama::Response>?
The result method returns the collected response data from handler operations.
Methods included from Concern
Constructor Details
#initialize(output: $stdout) ⇒ Collector
The initialize method sets up a new handler instance with the specified output destination and initializes an empty array for collecting responses.
defaults to $stdout
19 20 21 22 |
# File 'lib/ollama/handlers/collector.rb', line 19 def initialize(output: $stdout) super @array = [] end |
Instance Method Details
#call(response) ⇒ self
The call method processes a response by appending it to an internal array.
This method is responsible for handling individual responses during command execution by storing them in an internal array for later retrieval. It supports method chaining by returning the handler instance itself after processing.
34 35 36 37 |
# File 'lib/ollama/handlers/collector.rb', line 34 def call(response) @array << response self end |
#result ⇒ Array<Ollama::Response>?
The result method returns the collected response data from handler operations.
This method provides access to the accumulated results after a command has been executed with a handler that collects responses. It returns the internal array containing all responses that were processed by the handler.
48 49 50 |
# File 'lib/ollama/handlers/collector.rb', line 48 def result @array end |