前田です。

Pythonのftplib.pyをrubyに移植しました。
こんな感じで使うようになっています。

require "ftplib"

ftp = FTP.open("ftp.netlab.co.jp")
begin
   ftp.login("anonymous", "shugo / po.aianet.ne.jp")
   ftp.cwd("/pub/lang/ruby")
   ftp.dir do |line|
      print "LIST> ", line, "\n"
   end
ensure
   ftp.quit
end

socket.cへのパッチとftplib.rb.gzをuuencodeしたものを
付けときます。

# これでホームページ更新用のスクリプトを書こっと。

-- 
前田 修吾

--- socket.c.orig Fri Jun 20 18:17:30 1997 +++ socket.c Fri Aug 8 13:27:28 1997 @@ -922,7 +922,7 @@ #ifdef THREAD thread_fd_writable(fd); #endif - if (to) { + if (RTEST(to)) { Check_Type(to, T_STRING); n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags), (struct sockaddr*)to->ptr, to->len); @@ -1174,6 +1174,10 @@ rb_define_method(cBasicSocket, "getsockname", bsock_getsockname, 0); rb_define_method(cBasicSocket, "getpeername", bsock_getpeername, 0); + rb_define_method(cBasicSocket, "send", sock_send, -1); + rb_define_method(cBasicSocket, "recv", sock_recv, -1); + rb_define_method(cBasicSocket, "recvfrom", sock_recvfrom, -1); + cTCPsocket = rb_define_class("TCPsocket", cBasicSocket); rb_define_singleton_method(cTCPsocket, "open", tcp_s_open, 2); rb_define_singleton_method(cTCPsocket, "new", tcp_s_open, 2); @@ -1215,10 +1219,6 @@ rb_define_method(cSocket, "bind", sock_bind, 1); rb_define_method(cSocket, "listen", sock_listen, 1); rb_define_method(cSocket, "accept", sock_accept, 0); - - rb_define_method(cSocket, "send", sock_send, -1); - rb_define_method(cSocket, "recv", sock_recv, -1); - rb_define_method(cSocket, "recvfrom", sock_recv, -1); rb_define_singleton_method(cSocket, "socketpair", sock_s_socketpair, 3); rb_define_singleton_method(cSocket, "pair", sock_s_socketpair, 3);
begin 644 ftplib.rb.gz M'XL(",JBZC,``V9T<&QI8BYR8@#-&6MSTTCRL_,K&L%N[,6(V"'`!MC$!(=- M74A\M@/%95.4+(UC+;*D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