Class: MCP::Icon

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

Constant Summary collapse

SUPPORTED_THEMES =
["light", "dark"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mime_type: nil, sizes: nil, src: nil, theme: nil) ⇒ Icon

Returns a new instance of Icon.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/mcp/icon.rb', line 9

def initialize(mime_type: nil, sizes: nil, src: nil, theme: nil)
  raise ArgumentError, 'The value of theme must specify "light" or "dark".' if theme && !SUPPORTED_THEMES.include?(theme)

  @mime_type = mime_type
  @sizes = sizes
  @src = src
  @theme = theme
end

Instance Attribute Details

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



7
8
9
# File 'lib/mcp/icon.rb', line 7

def mime_type
  @mime_type
end

#sizesObject (readonly)

Returns the value of attribute sizes.



7
8
9
# File 'lib/mcp/icon.rb', line 7

def sizes
  @sizes
end

#srcObject (readonly)

Returns the value of attribute src.



7
8
9
# File 'lib/mcp/icon.rb', line 7

def src
  @src
end

#themeObject (readonly)

Returns the value of attribute theme.



7
8
9
# File 'lib/mcp/icon.rb', line 7

def theme
  @theme
end

Instance Method Details

#to_hObject



18
19
20
# File 'lib/mcp/icon.rb', line 18

def to_h
  { mimeType: mime_type, sizes: sizes, src: src, theme: theme }.compact
end