Class: Ollama::Response

Inherits:
JSON::GenericObject
  • Object
show all
Defined in:
lib/ollama/response.rb

Overview

A subclass of JSON::GenericObject that represents responses from the Ollama API.

This class serves as a specialized response object that extends JSON::GenericObject to provide structured access to API response data. It maintains the ability to convert to JSON format while preserving the response data in a hash-like structure.

Examples:

Accessing response data

response = Ollama::Response.new(key: 'value')
response[:key] # => 'value'

Instance Method Summary collapse

Instance Method Details

#as_json(*ignored) ⇒ Hash

Note:

This removes "json_class" attribute from hash for responses.

The as_json method converts the object's attributes into a JSON-compatible hash.

This method gathers all defined attributes of the object and constructs a hash representation, excluding any nil values or empty collections.

Parameters:

  • ignored (Array)

    ignored arguments

Returns:

  • (Hash)

    a hash containing the object's non-nil and non-empty attributes



21
22
23
# File 'lib/ollama/response.rb', line 21

def as_json(*ignored)
  to_hash
end