class Amberletters::TranscriptHistoryBuffer
This class offers a pass-through << operator and saves the most recent 256 bytes which have passed through.
Attributes
buffer[R]
Public Class Methods
new(transcript)
click to toggle source
# File lib/amberletters.rb, line 43 def initialize(transcript) @buffer = String.new @transcript = transcript end
Public Instance Methods
<<(output)
click to toggle source
# File lib/amberletters.rb, line 48 def <<(output) @buffer << output @transcript << output length = [@buffer.length, 512].min @buffer = @buffer[-length, length] self end