Class: Ask::MCP::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/ask/mcp/prompt.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description: nil, arguments: []) ⇒ Prompt

Returns a new instance of Prompt.



8
9
10
11
12
# File 'lib/ask/mcp/prompt.rb', line 8

def initialize(name:, description: nil, arguments: [])
  @name = name
  @description = description
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



6
7
8
# File 'lib/ask/mcp/prompt.rb', line 6

def arguments
  @arguments
end

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/ask/mcp/prompt.rb', line 6

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/ask/mcp/prompt.rb', line 6

def name
  @name
end

Class Method Details

.from_h(hash) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/ask/mcp/prompt.rb', line 21

def self.from_h(hash)
  new(
    name: hash[:name] || hash["name"],
    description: hash[:description] || hash["description"],
    arguments: hash[:arguments] || hash["arguments"] || []
  )
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
# File 'lib/ask/mcp/prompt.rb', line 14

def to_h
  h = { name: @name }
  h[:description] = @description if @description
  h[:arguments] = @arguments if @arguments.any?
  h
end