-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathcontents.rb
More file actions
45 lines (36 loc) · 774 Bytes
/
contents.rb
File metadata and controls
45 lines (36 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# typed: strict
# frozen_string_literal: true
module MCP
class Resource
class Contents
attr_reader :uri, :mime_type
def initialize(uri:, mime_type: nil)
@uri = uri
@mime_type = mime_type
end
def to_h
{ uri:, mime_type: }.compact
end
end
class TextContents < Contents
attr_reader :text
def initialize(text:, uri:, mime_type:)
super(uri:, mime_type:)
@text = text
end
def to_h
super.merge(text:)
end
end
class BlobContents < Contents
attr_reader :data
def initialize(data:, uri:, mime_type:)
super(uri:, mime_type:)
@data = data
end
def to_h
super.merge(data:)
end
end
end
end