Class: ActionMCP::Content::Audio

Inherits:
Base
  • Object
show all
Defined in:
lib/action_mcp/content/audio.rb

Overview

Audio content includes a base64-encoded audio clip and its MIME type.

Instance Attribute Summary collapse

Attributes inherited from Base

#annotations, #type

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(data, mime_type, annotations: nil) ⇒ Audio

Initializes a new Audio content.

Parameters:

  • data (String)

    The base64-encoded audio data.

  • mime_type (String)

    The MIME type of the audio data.

  • annotations (Hash, nil) (defaults to: nil)

    Optional annotations for the audio content.



16
17
18
19
20
# File 'lib/action_mcp/content/audio.rb', line 16

def initialize(data, mime_type, annotations: nil)
  super("audio", annotations: annotations)
  @data = data
  @mime_type = mime_type
end

Instance Attribute Details

#dataString (readonly)

Returns:

  • (String)

    The base64-encoded audio data.

  • (String)

    The MIME type of the audio data.



9
10
11
# File 'lib/action_mcp/content/audio.rb', line 9

def data
  @data
end

#mime_typeString (readonly)

Returns:

  • (String)

    The base64-encoded audio data.

  • (String)

    The MIME type of the audio data.



9
10
11
# File 'lib/action_mcp/content/audio.rb', line 9

def mime_type
  @mime_type
end

Instance Method Details

#to_hHash

Returns a hash representation of the audio content.

Returns:

  • (Hash)

    The hash representation of the audio content.



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

def to_h
  super.merge(data: @data, mimeType: @mime_type)
end