Connecting to an FTP server with net/ftp using an FTP URL is a simple operation:

require 'net/ftp'
require 'uri'
uri = URI.parse('ftp://ftp.ruby-lang.org/')
Net::FTP.open(uri.host) do |ftp|
  ftp.login 'anonymous', 'me@privacy.net'
  ftp.passive = true
  ftp.list(uri.path) { |path| puts path }
end
Advertisements