This class implements the File Transfer Protocol. If you have used a command-line FTP program, and are familiar with the commands, you will be able to use this class easily. Some extra features are included to take advantage of Ruby’s style and strengths.
ftp = Net::FTP.new('ftp.netlab.co.jp') ftp.login files = ftp.chdir('pub/lang/ruby/contrib') files = ftp.list('n*') ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024) ftp.close
Net::FTP.open('ftp.netlab.co.jp') do |ftp| ftp.login files = ftp.chdir('pub/lang/ruby/contrib') files = ftp.list('n*') ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024) end
The following are the methods most likely to be useful to users:
MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/
The server’s last response.
The server’s last response code.
The server’s welcome message.
Sets or retrieves the resume status, which decides whether incomplete transfers are resumed or restarted. Default: false.
When true, all traffic to and from the server is written to +$stdout+. Default: false.
When true, the connection is in passive mode. Default: false.
When true, transfers are performed in binary mode. Default: true.