Net::FTP adding port as initialize/open parameter

Hello,

This is probably question to Rails Core:

Why there is no option to supply port parameter to Net::FTP.new/open ?

My suggestion is to add an port parameter to new and open so code below:

Net::FTP.new(“ftp.host.com”,“user”,“pass”, nil, ftp_port)
Net::FTP.open(“ftp.host.com”,“user”,“pass”, nil, ftp_port)

became valid.

Code required to do this:

require ‘net/ftp’
class Net::FTP
def initialize(host = nil, user = nil, passwd = nil, acct = nil, port
= FTP_PORT)
super()
@binary = true
@passive = false
@debug_mode = false
@resume = false
if host
connect(host,port)
if user
login(user, passwd, acct)
end
end
end

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

end

Also open would be written as here, so it accepts the same parameters as
new.

Best Regards.

Maciej

I mean Ruby Core :slight_smile:

Regards:)

Maciej Tomaka wrote:

I mean Ruby Core :slight_smile:

Regards:)

You could take advantage of ruby’s open classes and make a “patch” for
your use , making it what ftools is to File , or something like that :slight_smile: