Class: Rooibos::Message::Timer
- Inherits:
-
Data
- Object
- Data
- Rooibos::Message::Timer
- Includes:
- Predicates
- Defined in:
- lib/rooibos/message/timer.rb
Overview
Response from a timer command.
Timer commands fire after a delay. Pattern matching in UPDATE distinguishes multiple timers. Without structured responses, timers return bare symbols—hard to extend with elapsed time or other metadata.
This response includes the envelope for routing and elapsed time. Include Predicates for safe predicate calls on any message.
Use it to handle Command.wait or Command.tick completions.
Example
case msg
in { type: :timer, envelope: :dismiss }
model.with(notification: nil)
in { type: :timer, envelope: :animate, elapsed: }
model.with(frame: next_frame(elapsed))
end
Instance Attribute Summary collapse
-
#elapsed ⇒ Object
readonly
Returns the value of attribute elapsed.
-
#envelope ⇒ Object
readonly
Returns the value of attribute envelope.
Instance Method Summary collapse
-
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
-
#timer? ⇒ Boolean
Returns
truefor timer responses.
Methods included from Predicates
#==, #method_missing, #respond_to_missing?, #to_sym
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rooibos::Message::Predicates
Instance Attribute Details
#elapsed ⇒ Object (readonly)
Returns the value of attribute elapsed
30 31 32 |
# File 'lib/rooibos/message/timer.rb', line 30 def elapsed @elapsed end |
#envelope ⇒ Object (readonly)
Returns the value of attribute envelope
30 31 32 |
# File 'lib/rooibos/message/timer.rb', line 30 def envelope @envelope end |
Instance Method Details
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
Returns a hash with :type, :envelope, and :elapsed.
41 42 43 |
# File 'lib/rooibos/message/timer.rb', line 41 def deconstruct_keys(_keys) { type: :timer, envelope:, elapsed: } end |
#timer? ⇒ Boolean
Returns true for timer responses.
34 35 36 |
# File 'lib/rooibos/message/timer.rb', line 34 def timer? true end |