Class: MCP::Annotations
- Inherits:
-
Object
- Object
- MCP::Annotations
- Defined in:
- lib/mcp/annotations.rb
Constant Summary collapse
- SUPPORTED_AUDIENCES =
["user", "assistant"].freeze
Instance Attribute Summary collapse
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#last_modified ⇒ Object
readonly
Returns the value of attribute last_modified.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
-
#initialize(audience: nil, priority: nil, last_modified: nil) ⇒ Annotations
constructor
A new instance of Annotations.
- #to_h ⇒ Object
Constructor Details
#initialize(audience: nil, priority: nil, last_modified: nil) ⇒ Annotations
Returns a new instance of Annotations.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mcp/annotations.rb', line 9 def initialize(audience: nil, priority: nil, last_modified: nil) if audience && !(audience.is_a?(Array) && audience.all? { |role| SUPPORTED_AUDIENCES.include?(role) }) raise ArgumentError, 'The value of audience must be an array of "user" or "assistant".' end raise ArgumentError, "The value of priority must be between 0 and 1." if priority && !priority.between?(0, 1) @audience = audience @priority = priority @last_modified = last_modified end |
Instance Attribute Details
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
7 8 9 |
# File 'lib/mcp/annotations.rb', line 7 def audience @audience end |
#last_modified ⇒ Object (readonly)
Returns the value of attribute last_modified.
7 8 9 |
# File 'lib/mcp/annotations.rb', line 7 def last_modified @last_modified end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
7 8 9 |
# File 'lib/mcp/annotations.rb', line 7 def priority @priority end |
Instance Method Details
#to_h ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/mcp/annotations.rb', line 20 def to_h { audience: audience, priority: priority, lastModified: last_modified, }.compact end |