Method: Down::ChunkedIO#initialize

Defined in:
lib/down/chunked_io.rb

#initialize(chunks:, size: nil, on_close: nil, data: {}, rewindable: true, encoding: nil) ⇒ ChunkedIO

Returns a new instance of ChunkedIO.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/down/chunked_io.rb', line 30

def initialize(chunks:, size: nil, on_close: nil, data: {}, rewindable: true, encoding: nil)
  @chunks     = chunks
  @size       = size
  @on_close   = on_close
  @data       = data
  @encoding   = find_encoding(encoding || "binary")
  @rewindable = rewindable
  @buffer     = nil
  @position   = 0
  @next_chunk = nil
  @closed     = false

  retrieve_chunk # fetch first chunk so that we know whether the file is empty
end