Class: Thermal::Stargraphic::ChunkedByteBuffer
- Inherits:
-
Object
- Object
- Thermal::Stargraphic::ChunkedByteBuffer
- Defined in:
- lib/thermal/stargraphic/chunked_byte_buffer.rb
Overview
TODO: This is not used yet. It should be refactored as it doesn’t transparently extend ByteBuffer
Instance Method Summary collapse
- #<<(obj) ⇒ Object
- #chunks ⇒ Object
- #flush ⇒ Object
- #flush_base64 ⇒ Object
-
#initialize(max_chunk_bytes) ⇒ ChunkedByteBuffer
constructor
A new instance of ChunkedByteBuffer.
- #to_a ⇒ Object
- #to_base64 ⇒ Object
Constructor Details
#initialize(max_chunk_bytes) ⇒ ChunkedByteBuffer
Returns a new instance of ChunkedByteBuffer.
8 9 10 11 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 8 def initialize(max_chunk_bytes) @max_chunk_bytes = max_chunk_bytes @byte_counter = 0 end |
Instance Method Details
#<<(obj) ⇒ Object
13 14 15 16 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 13 def <<(obj) check_length(obj) append(obj) end |
#chunks ⇒ Object
18 19 20 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 18 def chunks @chunks ||= [::Thermal::ByteBuffer.new] end |
#flush ⇒ Object
30 31 32 33 34 35 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 30 def flush tmp = chunks @chunks = nil @byte_counter = 0 tmp end |
#flush_base64 ⇒ Object
37 38 39 40 41 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 37 def flush_base64 tmp = to_base64 flush tmp end |
#to_a ⇒ Object
26 27 28 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 26 def to_a chunks.map(&:to_a) end |
#to_base64 ⇒ Object
22 23 24 |
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 22 def to_base64 chunks.map(&:to_base64) end |