Class: Manceps::Task
- Inherits:
-
Object
- Object
- Manceps::Task
- Defined in:
- lib/manceps/task.rb
Overview
An MCP task for tracking long-running operations.
Constant Summary collapse
- STATUSES =
%w[pending running completed failed cancelled].freeze
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #cancelled? ⇒ Boolean
- #completed? ⇒ Boolean
- #done? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(data) ⇒ Task
constructor
A new instance of Task.
- #pending? ⇒ Boolean
- #running? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 15 16 |
# File 'lib/manceps/task.rb', line 10 def initialize(data) @id = data['id'] @status = data['status'] @result = data['result'] @error = data['error'] @metadata = data['metadata'] || data['_meta'] end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/manceps/task.rb', line 6 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/manceps/task.rb', line 6 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/manceps/task.rb', line 6 def @metadata end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/manceps/task.rb', line 6 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/manceps/task.rb', line 6 def status @status end |
Instance Method Details
#cancelled? ⇒ Boolean
34 35 36 |
# File 'lib/manceps/task.rb', line 34 def cancelled? status == 'cancelled' end |
#completed? ⇒ Boolean
26 27 28 |
# File 'lib/manceps/task.rb', line 26 def completed? status == 'completed' end |
#done? ⇒ Boolean
38 39 40 |
# File 'lib/manceps/task.rb', line 38 def done? completed? || failed? || cancelled? end |
#failed? ⇒ Boolean
30 31 32 |
# File 'lib/manceps/task.rb', line 30 def failed? status == 'failed' end |
#pending? ⇒ Boolean
18 19 20 |
# File 'lib/manceps/task.rb', line 18 def pending? status == 'pending' end |
#running? ⇒ Boolean
22 23 24 |
# File 'lib/manceps/task.rb', line 22 def running? status == 'running' end |