Method: Turbotlib::FTP#download

Defined in:
lib/turbotlib/ftp.rb

#download(remotefile) ⇒ File

Downloads a remote file.

Parameters:

  • remotefile (String)

    the name of the remote file

Returns:

  • (File)

    a local file with the remote file's contents



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/turbotlib/ftp.rb', line 56

def download(remotefile)
  info("get #{remotefile}")

  path = File.join(root_path, pwd, remotefile)

  if !Turbotlib.in_production? && File.exist?(path)
    File.open(path)
  else
    FileUtils.mkdir_p(File.dirname(path))
    File.open(path, 'w') do |f|
      getbinaryfile(remotefile, f.path)
    end
    File.open(path)
  end
end