Class: ClaudeAgentSDK::TaskUsage
- Inherits:
-
Object
- Object
- ClaudeAgentSDK::TaskUsage
- Defined in:
- lib/claude_agent_sdk/types.rb
Overview
Typed usage data for task progress and notifications
Instance Attribute Summary collapse
-
#duration_ms ⇒ Object
Returns the value of attribute duration_ms.
-
#tool_uses ⇒ Object
Returns the value of attribute tool_uses.
-
#total_tokens ⇒ Object
Returns the value of attribute total_tokens.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(total_tokens: 0, tool_uses: 0, duration_ms: 0) ⇒ TaskUsage
constructor
A new instance of TaskUsage.
Constructor Details
#initialize(total_tokens: 0, tool_uses: 0, duration_ms: 0) ⇒ TaskUsage
Returns a new instance of TaskUsage.
371 372 373 374 375 |
# File 'lib/claude_agent_sdk/types.rb', line 371 def initialize(total_tokens: 0, tool_uses: 0, duration_ms: 0) @total_tokens = total_tokens @tool_uses = tool_uses @duration_ms = duration_ms end |
Instance Attribute Details
#duration_ms ⇒ Object
Returns the value of attribute duration_ms.
369 370 371 |
# File 'lib/claude_agent_sdk/types.rb', line 369 def duration_ms @duration_ms end |
#tool_uses ⇒ Object
Returns the value of attribute tool_uses.
369 370 371 |
# File 'lib/claude_agent_sdk/types.rb', line 369 def tool_uses @tool_uses end |
#total_tokens ⇒ Object
Returns the value of attribute total_tokens.
369 370 371 |
# File 'lib/claude_agent_sdk/types.rb', line 369 def total_tokens @total_tokens end |
Class Method Details
.from_hash(hash) ⇒ Object
377 378 379 380 381 382 383 384 385 |
# File 'lib/claude_agent_sdk/types.rb', line 377 def self.from_hash(hash) return nil unless hash.is_a?(Hash) new( total_tokens: hash[:total_tokens] || hash['total_tokens'] || hash[:totalTokens] || hash['totalTokens'] || 0, tool_uses: hash[:tool_uses] || hash['tool_uses'] || hash[:toolUses] || hash['toolUses'] || 0, duration_ms: hash[:duration_ms] || hash['duration_ms'] || hash[:durationMs] || hash['durationMs'] || 0 ) end |