Class: ClaudeSDK::ContentBlock::ToolResult
- Inherits:
-
Object
- Object
- ClaudeSDK::ContentBlock::ToolResult
- Defined in:
- lib/claude_sdk/types.rb
Overview
Tool result content block
Instance Attribute Summary collapse
-
#content ⇒ Object
the result content.
-
#is_error ⇒ Object
Returns the value of attribute is_error.
-
#tool_use_id ⇒ Object
ID of the corresponding tool use.
Instance Method Summary collapse
-
#initialize(tool_use_id:, content: nil, is_error: nil) ⇒ ToolResult
constructor
A new instance of ToolResult.
-
#to_h ⇒ Hash
Serialized representation.
Constructor Details
#initialize(tool_use_id:, content: nil, is_error: nil) ⇒ ToolResult
Returns a new instance of ToolResult.
173 174 175 176 177 |
# File 'lib/claude_sdk/types.rb', line 173 def initialize(tool_use_id:, content: nil, is_error: nil) @tool_use_id = tool_use_id @content = content @is_error = is_error end |
Instance Attribute Details
#content ⇒ Object
the result content
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/claude_sdk/types.rb', line 167 class ToolResult attr_accessor :tool_use_id, :content, :is_error # @param tool_use_id [String] ID of the tool use # @param content [String, Array<Hash>, nil] result content # @param is_error [Boolean, nil] error flag def initialize(tool_use_id:, content: nil, is_error: nil) @tool_use_id = tool_use_id @content = content @is_error = is_error end # @return [Hash] serialized representation def to_h hash = { type: "tool_result", tool_use_id: tool_use_id } hash[:content] = content unless content.nil? hash[:is_error] = is_error unless is_error.nil? hash end end |
#is_error ⇒ Object
Returns the value of attribute is_error.
168 169 170 |
# File 'lib/claude_sdk/types.rb', line 168 def is_error @is_error end |
#tool_use_id ⇒ Object
ID of the corresponding tool use
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/claude_sdk/types.rb', line 167 class ToolResult attr_accessor :tool_use_id, :content, :is_error # @param tool_use_id [String] ID of the tool use # @param content [String, Array<Hash>, nil] result content # @param is_error [Boolean, nil] error flag def initialize(tool_use_id:, content: nil, is_error: nil) @tool_use_id = tool_use_id @content = content @is_error = is_error end # @return [Hash] serialized representation def to_h hash = { type: "tool_result", tool_use_id: tool_use_id } hash[:content] = content unless content.nil? hash[:is_error] = is_error unless is_error.nil? hash end end |
Instance Method Details
#to_h ⇒ Hash
Returns serialized representation.
180 181 182 183 184 185 |
# File 'lib/claude_sdk/types.rb', line 180 def to_h hash = { type: "tool_result", tool_use_id: tool_use_id } hash[:content] = content unless content.nil? hash[:is_error] = is_error unless is_error.nil? hash end |