Class: Thermal::Stargraphic::ChunkedByteBuffer

Inherits:
Object
  • Object
show all
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

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

#chunksObject



18
19
20
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 18

def chunks
  @chunks ||= [::Thermal::ByteBuffer.new]
end

#flushObject



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_base64Object



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_aObject



26
27
28
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 26

def to_a
  chunks.map(&:to_a)
end

#to_base64Object



22
23
24
# File 'lib/thermal/stargraphic/chunked_byte_buffer.rb', line 22

def to_base64
  chunks.map(&:to_base64)
end