Class: Turbotlib::FTP
- Inherits:
-
Net::FTP
- Object
- Net::FTP
- Turbotlib::FTP
- Extended by:
- Forwardable
- Defined in:
- lib/turbotlib/ftp.rb
Instance Attribute Summary collapse
-
#initialize_args ⇒ Object
readonly
Returns the value of attribute initialize_args.
-
#last_cmd ⇒ Object
readonly
Returns the value of attribute last_cmd.
-
#last_dir ⇒ Object
readonly
Returns the value of attribute last_dir.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
Instance Method Summary collapse
- #chdir(dirname) ⇒ Object
-
#download(remotefile) ⇒ File
Downloads a remote file.
-
#initialize(host = nil, user = nil, passwd = nil, acct = nil) ⇒ FTP
constructor
A new instance of FTP.
- #login(*args) ⇒ Object
- #nlst(dir = nil) ⇒ Object
Constructor Details
#initialize(host = nil, user = nil, passwd = nil, acct = nil) ⇒ FTP
Returns a new instance of FTP.
72 73 74 75 76 77 78 |
# 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 |
Instance Attribute Details
#initialize_args ⇒ Object (readonly)
Returns the value of attribute initialize_args.
48 49 50 |
# File 'lib/turbotlib/ftp.rb', line 48 def initialize_args @initialize_args end |
#last_cmd ⇒ Object (readonly)
Returns the value of attribute last_cmd.
48 49 50 |
# File 'lib/turbotlib/ftp.rb', line 48 def last_cmd @last_cmd end |
#last_dir ⇒ Object (readonly)
Returns the value of attribute last_dir.
48 49 50 |
# File 'lib/turbotlib/ftp.rb', line 48 def last_dir @last_dir end |
#logger ⇒ Object
Returns the value of attribute logger.
47 48 49 |
# File 'lib/turbotlib/ftp.rb', line 47 def logger @logger end |
#root_path ⇒ Object
Returns the value of attribute root_path.
47 48 49 |
# File 'lib/turbotlib/ftp.rb', line 47 def root_path @root_path end |
Instance Method Details
#chdir(dirname) ⇒ Object
94 95 96 97 98 99 |
# 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) ⇒ File
Downloads a remote file.
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 |
#login(*args) ⇒ Object
80 81 82 83 |
# File 'lib/turbotlib/ftp.rb', line 80 def login(*args) info('login') super end |
#nlst(dir = nil) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/turbotlib/ftp.rb', line 85 def nlst(dir = nil) if dir info("nlst #{dir}") else info('nlst') end super end |