[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Net::FTP adding port as initialize/open parameter

Maciej Tomaka

9/25/2008 10:11:00 AM

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
--
Posted via http://www.ruby-....

2 Answers

Maciej Tomaka

9/25/2008 11:06:00 AM

0

I mean Ruby Core :)

Regards:)
--
Posted via http://www.ruby-....

Lex Williams

9/25/2008 11:53:00 AM

0

Maciej Tomaka wrote:
> I mean Ruby Core :)
>
> 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 :)
--
Posted via http://www.ruby-....