Class: A2A::Artifact
- Inherits:
-
Object
- Object
- A2A::Artifact
- Defined in:
- lib/a2a/artifact.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, parts:, **kwargs) ⇒ Artifact
constructor
A new instance of Artifact.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, parts:, **kwargs) ⇒ Artifact
Returns a new instance of Artifact.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/a2a/artifact.rb', line 7 def initialize(id:, parts:, **kwargs) raise ArgumentError, "parts must contain at least one element" if Array(parts).empty? @id = id @parts = parts @name = kwargs[:name] @description = kwargs[:description] @extensions = kwargs[:extensions] @metadata = kwargs[:metadata] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/a2a/artifact.rb', line 5 def description @description end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
5 6 7 |
# File 'lib/a2a/artifact.rb', line 5 def extensions @extensions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/a2a/artifact.rb', line 5 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/a2a/artifact.rb', line 5 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/a2a/artifact.rb', line 5 def name @name end |
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
5 6 7 |
# File 'lib/a2a/artifact.rb', line 5 def parts @parts end |
Class Method Details
.from_h(hash) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/a2a/artifact.rb', line 18 def self.from_h(hash) new( id: hash.fetch("artifactId"), name: hash["name"], description: hash["description"], parts: Array(hash["parts"]).map { Part.from_h(_1) }, extensions: hash["extensions"], metadata: hash["metadata"] ) end |
Instance Method Details
#to_h ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/a2a/artifact.rb', line 29 def to_h { "parts" => parts.map(&:to_h), "artifactId" => id, "name" => name, "description" => description, "extensions" => extensions, "metadata" => }.compact end |