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  ⇒ Ollama::Response, ... 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The result method returns the collected response data from handler operations. 
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 ⇒ Ollama::Response, ... (readonly)
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, such as Collector or Single handlers.
| 39 40 41 | # File 'lib/ollama/handlers/concern.rb', line 39 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.
processing
| 61 62 63 | # File 'lib/ollama/handlers/concern.rb', line 61 def to_proc -> response { call(response) } end |