Downloading files from an FTP server is easy if you know the filename and what type of file you’re trying to download. Net::FTP provides two useful methods to download files, getbinaryfile and gettextfile. Plain text files and binary files (such as images, sounds, or applications) are sent in a different way, so it’s essential you use the correct method. In most situations you’ll be aware ahead of time which technique is required. Here’s an example showing how to download a binary file from the official Ruby FTP server:

require 'net/ftp'
ftp = Net::FTP.new('ftp.ruby-lang.org')
ftp.passive = true
ftp.login
ftp.chdir('/pub/ruby/1.8')
ftp.getbinaryfile('1.8.2-patch1.gz')
ftp.close