Class: LLM::Schema::Array

Inherits:
Leaf
  • Object
show all
Defined in:
lib/llm/schema/array.rb

Overview

The LLM::Schema::Array class represents an array value in a JSON schema. It is a subclass of LLM::Schema::Leaf and provides methods that can act as constraints.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Leaf

#==, #const, #default, #description, #enum, #optional, #optional?, #required, #required?

Constructor Details

#initialize(items) ⇒ Array

Returns a new instance of Array.



17
18
19
# File 'lib/llm/schema/array.rb', line 17

def initialize(items)
  @items = items
end

Class Method Details

.[](type) ⇒ LLM::Schema::Array

Returns an array for the given type

Returns:



13
14
15
# File 'lib/llm/schema/array.rb', line 13

def self.[](type)
  new(type.new)
end

Instance Method Details

#to_hObject



21
22
23
# File 'lib/llm/schema/array.rb', line 21

def to_h
  super.merge!({type: "array", items:})
end

#to_json(options = {}) ⇒ Object



25
26
27
# File 'lib/llm/schema/array.rb', line 25

def to_json(options = {})
  to_h.to_json(options)
end