Method: Net::FTP.open
- Defined in:
- lib/net/ftp.rb
.open(host, user = nil, passwd = nil, acct = nil) ⇒ Object
A synonym for FTP.new, but with a mandatory host parameter.
If a block is given, it is passed the FTP object, which will be closed when the block finishes, or when an exception is raised.
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/net/ftp.rb', line 131 def FTP.open(host, user = nil, passwd = nil, acct = nil) if block_given? ftp = new(host, user, passwd, acct) begin yield ftp ensure ftp.close end else new(host, user, passwd, acct) end end |