Class: A2A::Types::TextPart
- Defined in:
- lib/a2a/types/part.rb
Overview
Represents a text part in a message
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Part
Class Method Summary collapse
-
.from_h(hash) ⇒ TextPart
Create a TextPart from a hash.
Instance Method Summary collapse
-
#initialize(text:, metadata: nil) ⇒ TextPart
constructor
Initialize a new text part.
- #validate! ⇒ Object private
Methods inherited from BaseModel
#==, #camelize, from_json, #hash, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type
Constructor Details
#initialize(text:, metadata: nil) ⇒ TextPart
Initialize a new text part
63 64 65 66 |
# File 'lib/a2a/types/part.rb', line 63 def initialize(text:, metadata: nil) @text = text super(kind: PART_KIND_TEXT, metadata: ) end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
56 57 58 |
# File 'lib/a2a/types/part.rb', line 56 def text @text end |
Class Method Details
.from_h(hash) ⇒ TextPart
Create a TextPart from a hash
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/a2a/types/part.rb', line 73 def self.from_h(hash) return hash if hash.is_a?(TextPart) return nil if hash.nil? # Convert string keys to symbols and snake_case camelCase keys normalized_hash = {} hash.each do |key, value| snake_key = BaseModel.underscore(key.to_s).to_sym normalized_hash[snake_key] = value unless snake_key == :kind end new(**normalized_hash) end |
Instance Method Details
#validate! ⇒ Object (private)
89 90 91 92 93 |
# File 'lib/a2a/types/part.rb', line 89 def validate! super validate_required(:text) validate_type(:text, String) end |