class Turbotlib::FTP
Attributes
initialize_args[R]
last_cmd[R]
last_dir[R]
logger[RW]
root_path[RW]
Public Class Methods
new(host = nil, user = nil, passwd = nil, acct = nil)
click to toggle source
Calls superclass method
# File lib/turbotlib/ftp.rb, line 72 def initialize(host = nil, user = nil, passwd = nil, acct = nil) # Store so we can recreate an FTP client. @initialize_args = [host, user, passwd, acct] @last_dir = Pathname.new('') @last_cmd = nil super end
Public Instance Methods
chdir(dirname)
click to toggle source
Calls superclass method
# File lib/turbotlib/ftp.rb, line 94 def chdir(dirname) info("chdir #{dirname}") super # Store so we can resume from the directory. @last_dir += dirname end
download(remotefile)
click to toggle source
Downloads a remote file.
@param [String] remotefile the name of the remote file @return [File] a local file with the remote file's contents
# 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
login(*args)
click to toggle source
Calls superclass method
# File lib/turbotlib/ftp.rb, line 80 def login(*args) info('login') super end
nlst(dir = nil)
click to toggle source
Calls superclass method
# File lib/turbotlib/ftp.rb, line 85 def nlst(dir = nil) if dir info("nlst #{dir}") else info('nlst') end super end
Private Instance Methods
putline(line)
click to toggle source
Calls superclass method
# File lib/turbotlib/ftp.rb, line 103 def putline(line) # Store so we can report the command that errored. @last_cmd = line super end