Class: A2A::Part::Text

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, media_type: nil, filename: nil, metadata: nil) ⇒ Text

Returns a new instance of Text.



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

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

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



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

def filename
  @filename
end

#media_typeObject (readonly)

Returns the value of attribute media_type.



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

def media_type
  @media_type
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Class Method Details

.from_h(hash) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/a2a/part/text.rb', line 15

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

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
31
# File 'lib/a2a/part/text.rb', line 24

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