Class: A2A::Types::FileWithUri

Inherits:
FileBase show all
Defined in:
lib/a2a/types/part.rb

Overview

Represents a file with a URI reference

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FileBase

from_h

Methods inherited from BaseModel

#==, #camelize, from_h, from_json, #hash, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type

Constructor Details

#initialize(name:, mime_type:, uri:) ⇒ FileWithUri

Initialize a new file with URI

Parameters:

  • name (String)

    The file name

  • mime_type (String)

    The MIME type

  • uri (String)

    The file URI



263
264
265
266
267
268
# File 'lib/a2a/types/part.rb', line 263

def initialize(name:, mime_type:, uri:)
  @name = name
  @mime_type = mime_type
  @uri = uri
  validate!
end

Instance Attribute Details

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



255
256
257
# File 'lib/a2a/types/part.rb', line 255

def mime_type
  @mime_type
end

#nameObject (readonly)

Returns the value of attribute name.



255
256
257
# File 'lib/a2a/types/part.rb', line 255

def name
  @name
end

#uriObject (readonly)

Returns the value of attribute uri.



255
256
257
# File 'lib/a2a/types/part.rb', line 255

def uri
  @uri
end

Instance Method Details

#validate!Object (private)



272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/a2a/types/part.rb', line 272

def validate!
  validate_required(:name, :mime_type, :uri)
  validate_type(:name, String)
  validate_type(:mime_type, String)
  validate_type(:uri, String)

  # Basic URI validation
  begin
    require "uri"
    URI.parse(@uri)
  rescue URI::InvalidURIError
    raise ArgumentError, "Invalid URI: #{@uri}"
  end
end