Class: Riffer::StreamEvents::Interrupt
- Defined in:
- lib/riffer/stream_events/interrupt.rb
Overview
Represents an interrupt event during streaming.
Emitted when a callback interrupts the agent loop via throw :riffer_interrupt.
Instance Attribute Summary collapse
-
#reason ⇒ Object
readonly
The reason provided with the interrupt, if any.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(reason: nil) ⇒ Interrupt
constructor
– : (?reason: (String | Symbol)?) -> void.
-
#to_h ⇒ Object
Converts the event to a hash.
Constructor Details
#initialize(reason: nil) ⇒ Interrupt
– : (?reason: (String | Symbol)?) -> void
13 14 15 16 |
# File 'lib/riffer/stream_events/interrupt.rb', line 13 def initialize(reason: nil) super(role: :system) @reason = reason end |
Instance Attribute Details
#reason ⇒ Object (readonly)
The reason provided with the interrupt, if any.
9 10 11 |
# File 'lib/riffer/stream_events/interrupt.rb', line 9 def reason @reason end |
Instance Method Details
#to_h ⇒ Object
Converts the event to a hash.
– : () -> Hash[Symbol, untyped]
22 23 24 25 26 |
# File 'lib/riffer/stream_events/interrupt.rb', line 22 def to_h h = {role: @role, interrupt: true} h[:reason] = @reason if @reason h end |