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.

Example

require 'net/ftp'

Example 1

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

Example 2

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

Major Methods

The following are the methods most likely to be useful to users:

Aliases

  • last_response_code

Constants

MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/

Attributes

[RW] binary

When true, transfers are performed in binary mode. Default: true.

[RW] passive

When true, the connection is in passive mode. Default: false.

[RW] debug_mode

When true, all traffic to and from the server is written to +$stdout+. Default: false.

[RW] resume

Sets or retrieves the resume status, which decides whether incomplete transfers are resumed or restarted. Default: false.

[R] welcome

The server’s welcome message.

[R] last_response_code

The server’s last response code.

[R] last_response

The server’s last response.

Show files where this class is defined (1 file)
Register or log in to add new notes.