Class: OpenRouter::Schema::ItemsBuilder
- Inherits:
-
Object
- Object
- OpenRouter::Schema::ItemsBuilder
- Defined in:
- lib/open_router/schema.rb
Overview
Internal class for building array items
Instance Method Summary collapse
- #boolean(description: nil, **options) ⇒ Object
-
#initialize ⇒ ItemsBuilder
constructor
A new instance of ItemsBuilder.
- #integer(description: nil, **options) ⇒ Object
- #number(description: nil, **options) ⇒ Object
- #object(&block) ⇒ Object
- #string(description: nil, **options) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ ItemsBuilder
Returns a new instance of ItemsBuilder.
297 298 299 |
# File 'lib/open_router/schema.rb', line 297 def initialize @items = {} end |
Instance Method Details
#boolean(description: nil, **options) ⇒ Object
319 320 321 322 323 |
# File 'lib/open_router/schema.rb', line 319 def boolean(description: nil, **) @items = { type: "boolean" } @items[:description] = description if description @items.merge!() end |
#integer(description: nil, **options) ⇒ Object
307 308 309 310 311 |
# File 'lib/open_router/schema.rb', line 307 def integer(description: nil, **) @items = { type: "integer" } @items[:description] = description if description @items.merge!() end |
#number(description: nil, **options) ⇒ Object
313 314 315 316 317 |
# File 'lib/open_router/schema.rb', line 313 def number(description: nil, **) @items = { type: "number" } @items[:description] = description if description @items.merge!() end |
#object(&block) ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/open_router/schema.rb', line 325 def object(&block) @items = { type: "object", properties: {}, required: [], additionalProperties: false } return unless block_given? object_builder = SchemaBuilder.new object_builder.instance_eval(&block) nested_schema = object_builder.to_h @items[:properties] = nested_schema[:properties] @items[:required] = nested_schema[:required] return unless nested_schema.key?(:additionalProperties) @items[:additionalProperties] = nested_schema[:additionalProperties] end |
#string(description: nil, **options) ⇒ Object
301 302 303 304 305 |
# File 'lib/open_router/schema.rb', line 301 def string(description: nil, **) @items = { type: "string" } @items[:description] = description if description @items.merge!() end |
#to_h ⇒ Object
341 342 343 |
# File 'lib/open_router/schema.rb', line 341 def to_h @items end |