Class: Ask::MCP::Resource
- Inherits:
-
Object
- Object
- Ask::MCP::Resource
- Defined in:
- lib/ask/mcp/resource.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#icons ⇒ Object
readonly
Returns the value of attribute icons.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(uri:, name:, description: nil, mime_type: nil, title: nil, icons: []) ⇒ Resource
constructor
A new instance of Resource.
- #to_h ⇒ Object
Constructor Details
#initialize(uri:, name:, description: nil, mime_type: nil, title: nil, icons: []) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 12 13 14 15 |
# File 'lib/ask/mcp/resource.rb', line 8 def initialize(uri:, name:, description: nil, mime_type: nil, title: nil, icons: []) @uri = uri @name = name @description = description @mime_type = mime_type @title = title @icons = icons end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/ask/mcp/resource.rb', line 6 def description @description end |
#icons ⇒ Object (readonly)
Returns the value of attribute icons.
6 7 8 |
# File 'lib/ask/mcp/resource.rb', line 6 def icons @icons end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
6 7 8 |
# File 'lib/ask/mcp/resource.rb', line 6 def mime_type @mime_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/ask/mcp/resource.rb', line 6 def name @name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/ask/mcp/resource.rb', line 6 def title @title end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/ask/mcp/resource.rb', line 6 def uri @uri end |
Class Method Details
.from_h(hash) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ask/mcp/resource.rb', line 26 def self.from_h(hash) new( uri: hash[:uri] || hash["uri"], name: hash[:name] || hash["name"], description: hash[:description] || hash["description"], mime_type: hash[:mimeType] || hash["mime_type"] || hash[:mime_type], title: hash[:title] || hash["title"], icons: hash[:icons] || hash["icons"] || [] ) end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/ask/mcp/resource.rb', line 17 def to_h h = { uri: @uri, name: @name } h[:title] = @title if @title h[:description] = @description if @description h[:mimeType] = @mime_type if @mime_type h[:icons] = @icons if @icons.any? h end |