Class: A2A::Types::FileWithUri
- Defined in:
- lib/a2a/types/part.rb
Overview
Represents a file with a URI reference
Instance Attribute Summary collapse
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(name:, mime_type:, uri:) ⇒ FileWithUri
constructor
Initialize a new file with URI.
- #validate! ⇒ Object private
Methods inherited from FileBase
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
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_type ⇒ Object (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 |
#name ⇒ Object (readonly)
Returns the value of attribute name.
255 256 257 |
# File 'lib/a2a/types/part.rb', line 255 def name @name end |
#uri ⇒ Object (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 |