Class: EventMachine::FtpClient::DataConnection

Inherits:
Connection
  • Object
show all
Includes:
Deferrable
Defined in:
lib/em-ftp-client/data_connection.rb

Instance Method Summary collapse

Instance Method Details

#connection_completedObject



14
15
16
# File 'lib/em-ftp-client/data_connection.rb', line 14

def connection_completed
  @on_connect.call(self) if @on_connect
end

#on_connect(&blk) ⇒ Object



6
# File 'lib/em-ftp-client/data_connection.rb', line 6

def on_connect(&blk); @on_connect = blk; end

#post_initObject



10
11
12
# File 'lib/em-ftp-client/data_connection.rb', line 10

def post_init
  @buf = ''
end

#receive_data(data) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/em-ftp-client/data_connection.rb', line 18

def receive_data(data)
  @buf += data
  if @stream
    @stream.call(@buf)
    @buf = ''
  end
end

#send_file(filename) ⇒ Object



26
27
28
29
# File 'lib/em-ftp-client/data_connection.rb', line 26

def send_file(filename)
 send_file_data(filename)
  close_connection_after_writing
end

#stream(&blk) ⇒ Object



8
# File 'lib/em-ftp-client/data_connection.rb', line 8

def stream(&blk); @stream = blk; end

#unbindObject



31
32
33
# File 'lib/em-ftp-client/data_connection.rb', line 31

def unbind
  succeed(@buf)
end