Class: OmniAI::Schema::Format
- Inherits:
-
Object
- Object
- OmniAI::Schema::Format
- Defined in:
- lib/omniai/schema/format.rb
Overview
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, schema:) ⇒ Format
constructor
A new instance of Format.
- #parse(text) ⇒ Hash
- #serialize ⇒ Hash
Constructor Details
#initialize(name:, schema:) ⇒ Format
Returns a new instance of Format.
44 45 46 47 |
# File 'lib/omniai/schema/format.rb', line 44 def initialize(name:, schema:) @name = name @schema = schema end |
Instance Attribute Details
#name ⇒ String
20 21 22 |
# File 'lib/omniai/schema/format.rb', line 20 def name @name end |
#schema ⇒ OmniAI::Schema::Object
24 25 26 |
# File 'lib/omniai/schema/format.rb', line 24 def schema @schema end |
Class Method Details
.deserialize(data) ⇒ OmniAI::Schema::Format
35 36 37 38 39 40 |
# File 'lib/omniai/schema/format.rb', line 35 def self.deserialize(data) name = data["name"] || data[:name] schema = OmniAI::Schema.deserialize(data["schema"] || data[:schema]) new(name:, schema:) end |
Instance Method Details
#parse(text) ⇒ Hash
66 67 68 |
# File 'lib/omniai/schema/format.rb', line 66 def parse(text) schema.parse(JSON.parse(text)) end |
#serialize ⇒ Hash
53 54 55 56 57 58 |
# File 'lib/omniai/schema/format.rb', line 53 def serialize { name:, schema: schema.serialize, } end |