けいじゅ@日本ラショナルソフトウェアです. In [ruby-list :19059 ] the message: "[ruby-list:19059] Re: [book] forwarding.rb ", on Nov/30 20:14(JST) TAKEUCHi Kahori writes: >たけうちです。 >forwarding.rb のパッチです。 どうもです. # といっても既に私の手の内では直っていました(^^;;; # 本に反映するのは忘れていました... 5/18にソースコードを送って, 修正し # たのが8/16ですので間に合ったはずなんですが.... あまりに期間が空いたの # で忘れてしまったんですね.... >このパッチの部分のほかにも、どう直すべきかわからないところが >1個所あります(理解しきれていなくて、なにが正しいかわかりませ >ん)。自分では使っていないので、得意技の「ま、いっか」を発動 >して放ってあります。 > >module SingleForwarding の中で、 > > def def_singleton_delegator(accessor, method, ali = method) > >とあるのに、このメソッド中では ali が使われていません。使わ >れるように直すのが正しいのか、引数の ali を消すのが正しいの >か…。それとも単なるわたしのかんちがいで、これであっているの >でしょうか。 いやあっていないですね(^^;;; こちらの件は, 手元のものもなおっていません でした. チェックありがとうございます(__;;; ヘッダ部分がちょっと欠ているので, 一応全送します. -- forwarding.rb #!/usr/local/bin/ruby # # forwarding.rb - # $Release Version: 1.0$ # $Revision: 1.2 $ # $Date: 1999/12/01 03:28:01 $ # by Keiju ISHITSUKA(Nippon Rational Inc.) # original definition by delegator.rb # -- # Usage: # # class Foo # extend Forwarding # def_delegators("@out", "printf", "print") # def_delegators(:@in, :gets) # def_delegator(:@contents, :[], "content_at") # end # f = Foo.new # f.printf ... # f.gets # f.content_at(1) # f.extend SingleForwarding # f.def_delegator("@out", :puts) # f.puts ... # # module Forwarding def def_instance_delegators(accessor, *methods) for method in methods def_instance_delegator(accessor, method) end end def def_instance_delegator(accessor, method, ali = method) accessor = accessor.id2name if accessor.kind_of?(Integer) method = method.id2name if method.kind_of?(Integer) ali = ali.id2name if ali.kind_of?(Integer) module_eval "def #{ali}(*args,&block); #{accessor}.__send__(:#{method}, *args,&block); end" end alias def_delegators def_instance_delegators alias def_delegator def_instance_delegator end module SingleForwarding def def_singleton_delegators(accessor, *methods) for method in methods def_singleton_delegator(accessor, method) end end def def_singleton_delegator(accessor, method, ali = method) accessor = accessor.id2name if accessor.kind_of?(Integer) method = method.id2name if method.kind_of?(Integer) ali = ali.id2name if ali.kind_of?(Integer) instance_eval "def #{ali}(*args,&block); #{accessor}.__send__(:#{method}, *args,&block); end" end alias def_delegators def_singleton_delegators alias def_delegator def_singleton_delegator end __ ..............................石塚 圭樹@日本ラショナルソフトウェア... ----------------------------------->> e-mail: keiju / rational.com <<---