Class: A2A::Part::File

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/part/file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw: nil, url: nil, filename: nil, media_type: nil, metadata: nil) ⇒ File

Returns a new instance of File.



8
9
10
11
12
13
14
# File 'lib/a2a/part/file.rb', line 8

def initialize(raw: nil, url: nil, filename: nil, media_type: nil, metadata: nil)
  @raw = raw
  @url = url
  @filename = filename
  @media_type = media_type
  @metadata = 
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/a2a/part/file.rb', line 6

def filename
  @filename
end

#media_typeObject (readonly)

Returns the value of attribute media_type.



6
7
8
# File 'lib/a2a/part/file.rb', line 6

def media_type
  @media_type
end

#metadataObject (readonly)

Returns the value of attribute metadata.



6
7
8
# File 'lib/a2a/part/file.rb', line 6

def 
  @metadata
end

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/a2a/part/file.rb', line 6

def raw
  @raw
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/a2a/part/file.rb', line 6

def url
  @url
end

Class Method Details

.from_h(hash) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/a2a/part/file.rb', line 16

def self.from_h(hash)
  new(
    raw: hash["raw"],
    url: hash["url"],
    filename: hash["filename"],
    media_type: hash["mediaType"],
    metadata: hash["metadata"]
  )
end

Instance Method Details

#inline?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/a2a/part/file.rb', line 36

def inline?
  !raw.nil?
end

#remote?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/a2a/part/file.rb', line 40

def remote?
  !url.nil?
end

#to_hObject



26
27
28
29
30
31
32
33
34
# File 'lib/a2a/part/file.rb', line 26

def to_h
  {
    "raw" => raw,
    "url" => url,
    "filename" => filename,
    "mediaType" => media_type,
    "metadata" => 
  }.compact
end