Class: ActionMCP::Client::PromptBook::Prompt
- Inherits:
-
Object
- Object
- ActionMCP::Client::PromptBook::Prompt
- Defined in:
- lib/action_mcp/client/prompt_book.rb
Overview
Internal Prompt class to represent individual prompts
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#has_argument?(name) ⇒ Boolean
Check if the prompt has a specific argument.
-
#initialize(data) ⇒ Prompt
constructor
Initialize a new Prompt instance.
-
#optional_arguments ⇒ Array<Hash>
Get all optional arguments for this prompt.
-
#required_arguments ⇒ Array<Hash>
Get all required arguments for this prompt.
-
#to_h ⇒ Hash
Generate a hash representation of the prompt.
Constructor Details
#initialize(data) ⇒ Prompt
Initialize a new Prompt instance
76 77 78 79 80 |
# File 'lib/action_mcp/client/prompt_book.rb', line 76 def initialize(data) @name = data["name"] @description = data["description"] @arguments = data["arguments"] || [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
71 72 73 |
# File 'lib/action_mcp/client/prompt_book.rb', line 71 def arguments @arguments end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
71 72 73 |
# File 'lib/action_mcp/client/prompt_book.rb', line 71 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
71 72 73 |
# File 'lib/action_mcp/client/prompt_book.rb', line 71 def name @name end |
Instance Method Details
#has_argument?(name) ⇒ Boolean
Check if the prompt has a specific argument
100 101 102 |
# File 'lib/action_mcp/client/prompt_book.rb', line 100 def has_argument?(name) @arguments.any? { |arg| arg["name"] == name } end |
#optional_arguments ⇒ Array<Hash>
Get all optional arguments for this prompt
92 93 94 |
# File 'lib/action_mcp/client/prompt_book.rb', line 92 def optional_arguments @arguments.reject { |arg| arg["required"] } end |
#required_arguments ⇒ Array<Hash>
Get all required arguments for this prompt
85 86 87 |
# File 'lib/action_mcp/client/prompt_book.rb', line 85 def required_arguments @arguments.select { |arg| arg["required"] } end |
#to_h ⇒ Hash
Generate a hash representation of the prompt
107 108 109 110 111 112 113 |
# File 'lib/action_mcp/client/prompt_book.rb', line 107 def to_h { "name" => @name, "description" => @description, "arguments" => @arguments } end |