Class: Manceps::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/manceps/content.rb

Overview

A single content item returned by an MCP tool or prompt.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Content

Returns a new instance of Content.



8
9
10
11
12
13
14
15
# File 'lib/manceps/content.rb', line 8

def initialize(data)
  @type = data['type']
  @text = data['text']
  @data = data['data']        # base64 for image/audio
  @mime_type = data['mimeType']
  @uri = data['uri']          # for resource content
  @resource = data['resource'] # for resource_link type
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/manceps/content.rb', line 6

def data
  @data
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



6
7
8
# File 'lib/manceps/content.rb', line 6

def mime_type
  @mime_type
end

#resourceObject (readonly)

Returns the value of attribute resource.



6
7
8
# File 'lib/manceps/content.rb', line 6

def resource
  @resource
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/manceps/content.rb', line 6

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/manceps/content.rb', line 6

def type
  @type
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/manceps/content.rb', line 6

def uri
  @uri
end

Instance Method Details

#image?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/manceps/content.rb', line 21

def image?
  type == 'image'
end

#resource?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/manceps/content.rb', line 25

def resource?
  type == 'resource'
end

#resource_link?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/manceps/content.rb', line 29

def resource_link?
  type == 'resource_link'
end

#text?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/manceps/content.rb', line 17

def text?
  type == 'text'
end