class Pantry::Communication::FileService::SendingFile

Sending-side version of UploadInfo

Attributes

file[R]
path[R]

Public Class Methods

new(file_path, receiver_uuid, file_uuid) click to toggle source
# File lib/pantry/communication/file_service/file_progress.rb, line 34
def initialize(file_path, receiver_uuid, file_uuid)
  super()
  @path = file_path
  @file_uuid = file_uuid
  @file = File.open(@path, "r")

  @receiver_uuid = receiver_uuid

  @file_size = @file.size
  @total_bytes_sent = 0

  Pantry.ui.progress_start(@file_size)
end

Public Instance Methods

finished!() click to toggle source
# File lib/pantry/communication/file_service/file_progress.rb, line 56
def finished!
  Pantry.ui.progress_finish

  @file.close
  super
end
finished?() click to toggle source
# File lib/pantry/communication/file_service/file_progress.rb, line 63
def finished?
  @total_bytes_sent == @file_size || @file.closed?
end
read(offset, bytes_to_read) click to toggle source
# File lib/pantry/communication/file_service/file_progress.rb, line 48
def read(offset, bytes_to_read)
  @total_bytes_sent += bytes_to_read
  Pantry.ui.progress_step(bytes_to_read)

  @file.seek(offset)
  @file.read(bytes_to_read)
end