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: [], title: nil, icons: []) ⇒ Prompt

Returns a new instance of Prompt.



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

def initialize(name:, description: nil, arguments: [], title: nil, icons: [])
  @name = name
  @description = description
  @arguments = arguments
  @title = title
  @icons = icons
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

#iconsObject (readonly)

Returns the value of attribute icons.



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

def icons
  @icons
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details

.from_h(hash) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/ask/mcp/prompt.rb', line 25

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

Instance Method Details

#to_hObject



16
17
18
19
20
21
22
23
# File 'lib/ask/mcp/prompt.rb', line 16

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