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.
255 256 257 |
# File 'lib/open_router/schema.rb', line 255 def initialize @items = {} end |
Instance Method Details
#boolean(description: nil, **options) ⇒ Object
277 278 279 280 281 |
# File 'lib/open_router/schema.rb', line 277 def boolean(description: nil, **) @items = { type: "boolean" } @items[:description] = description if description @items.merge!() end |
#integer(description: nil, **options) ⇒ Object
265 266 267 268 269 |
# File 'lib/open_router/schema.rb', line 265 def integer(description: nil, **) @items = { type: "integer" } @items[:description] = description if description @items.merge!() end |
#number(description: nil, **options) ⇒ Object
271 272 273 274 275 |
# File 'lib/open_router/schema.rb', line 271 def number(description: nil, **) @items = { type: "number" } @items[:description] = description if description @items.merge!() end |
#object(&block) ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/open_router/schema.rb', line 283 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
259 260 261 262 263 |
# File 'lib/open_router/schema.rb', line 259 def string(description: nil, **) @items = { type: "string" } @items[:description] = description if description @items.merge!() end |
#to_h ⇒ Object
299 300 301 |
# File 'lib/open_router/schema.rb', line 299 def to_h @items end |