Module: Ollama::JSONLoader

Included in:
Client::Configuration::Config, Options
Defined in:
lib/ollama/json_loader.rb

Overview

Examples:

Loading configuration from a JSON file

config = MyConfigClass.load_from_json('path/to/config.json')

Instance Method Summary collapse

Instance Method Details

#load_from_json(path) ⇒ self

The load_from_json method loads configuration data from a JSON file.

This method reads the specified JSON file and uses its contents to initialize a new instance of the class by passing the parsed data as keyword arguments to the constructor.

Parameters:

  • path (String)

    the filesystem path to the JSON configuration file

Returns:

  • (self)

    a new instance of the class initialized with the JSON data



19
20
21
22
# File 'lib/ollama/json_loader.rb', line 19

def load_from_json(path)
  json = File.read(path)
  new(**config_hash = JSON.parse(json, symbolize_names: true))
end