Class: RobotLab::RobotMessage
- Inherits:
-
Data
- Object
- Data
- RobotLab::RobotMessage
- Defined in:
- lib/robot_lab/robot_message.rb
Overview
Typed message envelope for bus-based robot communication.
RobotMessage is a Data class (immutable value object) that wraps content sent between robots via a TypedBus channel.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#in_reply_to ⇒ Object
readonly
Returns the value of attribute in_reply_to.
Class Method Summary collapse
-
.build(id:, from:, content:, in_reply_to: nil) ⇒ RobotMessage
Build a RobotMessage with in_reply_to defaulting to nil.
Instance Method Summary collapse
-
#key ⇒ String
Composite identity key: “from:id”.
-
#reply? ⇒ Boolean
Whether this message is a reply to another message.
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content
22 23 24 |
# File 'lib/robot_lab/robot_message.rb', line 22 def content @content end |
#from ⇒ Object (readonly)
Returns the value of attribute from
22 23 24 |
# File 'lib/robot_lab/robot_message.rb', line 22 def from @from end |
#id ⇒ Object (readonly)
Returns the value of attribute id
22 23 24 |
# File 'lib/robot_lab/robot_message.rb', line 22 def id @id end |
#in_reply_to ⇒ Object (readonly)
Returns the value of attribute in_reply_to
22 23 24 |
# File 'lib/robot_lab/robot_message.rb', line 22 def in_reply_to @in_reply_to end |
Class Method Details
.build(id:, from:, content:, in_reply_to: nil) ⇒ RobotMessage
Build a RobotMessage with in_reply_to defaulting to nil.
30 31 32 |
# File 'lib/robot_lab/robot_message.rb', line 30 def self.build(id:, from:, content:, in_reply_to: nil) new(id: id, from: from, content: content, in_reply_to: in_reply_to) end |
Instance Method Details
#key ⇒ String
Composite identity key: “from:id”
37 |
# File 'lib/robot_lab/robot_message.rb', line 37 def key = "#{from}:#{id}" |
#reply? ⇒ Boolean
Whether this message is a reply to another message.
42 |
# File 'lib/robot_lab/robot_message.rb', line 42 def reply? = !in_reply_to.nil? |