Class: Daytona::MultipartDownloadStreamParser

Inherits:
Object
  • Object
show all
Defined in:
lib/daytona/file_transfer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&on_file_chunk) ⇒ MultipartDownloadStreamParser

Returns a new instance of MultipartDownloadStreamParser.



23
24
25
26
27
28
29
30
31
# File 'lib/daytona/file_transfer.rb', line 23

def initialize(&on_file_chunk)
  @on_file_chunk = on_file_chunk
  @boundary_token = nil
  @buffer = String.new.b
  @state = :preamble
  @part_name = nil
  @part_total_bytes = nil
  @error_buffer = String.new.b
end

Instance Attribute Details

#boundary_token=(value) ⇒ Object (writeonly)

Sets the attribute boundary_token

Parameters:

  • value

    the value to set the attribute boundary_token to.



21
22
23
# File 'lib/daytona/file_transfer.rb', line 21

def boundary_token=(value)
  @boundary_token = value
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



19
20
21
# File 'lib/daytona/file_transfer.rb', line 19

def error_message
  @error_message
end

#part_total_bytesObject (readonly)

Returns the value of attribute part_total_bytes.



20
21
22
# File 'lib/daytona/file_transfer.rb', line 20

def part_total_bytes
  @part_total_bytes
end

Instance Method Details

#<<(chunk) ⇒ Object



33
34
35
36
# File 'lib/daytona/file_transfer.rb', line 33

def <<(chunk)
  @buffer << chunk.b
  process!
end

#finish!Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/daytona/file_transfer.rb', line 38

def finish!
  process!

  return if @state == :done || @buffer.empty?

  emit(@buffer)
  finalize_part!
  @buffer = String.new.b
  @state = :done
end