Class: A2A::Types::FileBase
- Defined in:
- lib/a2a/types/part.rb
Overview
Base class for file representations
Direct Known Subclasses
Class Method Summary collapse
-
.from_h(hash) ⇒ FileBase
Create a file from a hash (factory method).
Methods inherited from BaseModel
#==, #camelize, from_json, #hash, #initialize, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type
Constructor Details
This class inherits a constructor from A2A::Types::BaseModel
Class Method Details
.from_h(hash) ⇒ FileBase
Create a file from a hash (factory method)
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/a2a/types/part.rb', line 192 def self.from_h(hash) return nil if hash.nil? if hash.key?(:bytes) || hash.key?("bytes") FileWithBytes.from_h(hash) elsif hash.key?(:uri) || hash.key?("uri") FileWithUri.from_h(hash) else raise ArgumentError, "File must have either 'bytes' or 'uri'" end end |