From: Sergey Avseyev Date: 2011-08-05T16:58:13+09:00 Subject: Re: Corrections in a Class On 08/04/2011 07:05 PM, Rubyist Rohit wrote: > I also want to improve the way it is written. > Hi, What about this code? require 'net/ftp' class RemoteConnection #Constants ServerName = "my FTP Server URL" UserName = "My Username" Password = "My Password" FilePath = "My remote Sub Folder" def self.connect_via_ftp #FTP instance @ftp = Net::FTP.new @ftp.connect(ServerName, 21) @ftp.login(UserName, Password) @ftp.chdir(FilePath) #@ftp.getbinaryfile(filename) end def self.disconnect_ftp if @ftp @ftp.close @ftp = nil end end end # USAGE RemoteConnection.connect_via_ftp RemoteConnection.disconnect_ftp