Method: Net::FTP.open

Defined in:
lib/net/ftp.rb

.open(host, *args) ⇒ 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.



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/net/ftp.rb', line 175

def FTP.open(host, *args)
  if block_given?
    ftp = new(host, *args)
    begin
      yield ftp
    ensure
      ftp.close
    end
  else
    new(host, *args)
  end
end