module Blather::FileTransfer::SimpleFileReceiver

Simple handler for incoming file transfers

You can define your own handler and pass it to the accept method.

Public Class Methods

new(path, size) click to toggle source
# File lib/blather/file_transfer.rb, line 85
def initialize(path, size)
  @path = path
  @size = size
  @transferred = 0
end

Public Instance Methods

post_init() click to toggle source

@private

# File lib/blather/file_transfer.rb, line 92
def post_init
  @file = File.open(@path, "w")
end
receive_data(data) click to toggle source

@private

# File lib/blather/file_transfer.rb, line 97
def receive_data(data)
  @transferred += data.size
  @file.write data
end
unbind() click to toggle source

@private

# File lib/blather/file_transfer.rb, line 103
def unbind
  @file.close
  File.delete(@path) unless @transferred == @size
end