Class: A2A::Task::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/task/status.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state:, message: nil, timestamp: nil) ⇒ Status

Returns a new instance of Status.



8
9
10
11
12
# File 'lib/a2a/task/status.rb', line 8

def initialize(state:, message: nil, timestamp: nil)
  @state = state
  @message = message
  @timestamp = timestamp
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/a2a/task/status.rb', line 6

def message
  @message
end

#stateObject (readonly)

Returns the value of attribute state.



6
7
8
# File 'lib/a2a/task/status.rb', line 6

def state
  @state
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/a2a/task/status.rb', line 6

def timestamp
  @timestamp
end

Class Method Details

.from_h(hash) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/a2a/task/status.rb', line 14

def self.from_h(hash)
  new(
    state: hash.fetch("state"),
    message: hash["message"] && Message.from_h(hash["message"]),
    timestamp: hash["timestamp"]
  )
end

Instance Method Details

#terminal?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/a2a/task/status.rb', line 30

def terminal?
  Task::State.terminal?(state)
end

#to_hObject



22
23
24
25
26
27
28
# File 'lib/a2a/task/status.rb', line 22

def to_h
  {
    "state" => state,
    "message" => message&.to_h,
    "timestamp" => timestamp
  }.compact
end