Class: AiStream::Stream::FrameSink

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_stream/stream.rb

Overview

A tiny sink adapter: turns Writer’s ‘sink << frame` into a yielded chunk.

Instance Method Summary collapse

Constructor Details

#initialize(&on_frame) ⇒ FrameSink

Returns a new instance of FrameSink.



69
70
71
# File 'lib/ai_stream/stream.rb', line 69

def initialize(&on_frame)
  @on_frame = on_frame
end

Instance Method Details

#<<(frame) ⇒ Object



73
74
75
76
# File 'lib/ai_stream/stream.rb', line 73

def <<(frame)
  @on_frame.call(frame)
  self
end