Class: Amberletters::TranscriptHistoryBuffer
- Inherits:
-
Object
- Object
- Amberletters::TranscriptHistoryBuffer
- Defined in:
- lib/amberletters.rb
Overview
This class offers a pass-through << operator and saves the most recent 256 bytes which have passed through.
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Instance Method Summary collapse
- #<<(output) ⇒ Object
-
#initialize(transcript) ⇒ TranscriptHistoryBuffer
constructor
A new instance of TranscriptHistoryBuffer.
Constructor Details
#initialize(transcript) ⇒ TranscriptHistoryBuffer
Returns a new instance of TranscriptHistoryBuffer.
43 44 45 46 |
# File 'lib/amberletters.rb', line 43 def initialize(transcript) @buffer = String.new @transcript = transcript end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
41 42 43 |
# File 'lib/amberletters.rb', line 41 def buffer @buffer end |
Instance Method Details
#<<(output) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/amberletters.rb', line 48 def <<(output) @buffer << output @transcript << output length = [@buffer.length, 512].min @buffer = @buffer[-length, length] self end |