From: Toshiro Kuwabara Date: 2001-04-03T01:24:12+09:00 Subject: [ruby-list:29060] Re: forwardable-1.0 release Toshです。 In message "[ruby-list:29057] Re: forwardable-1.0 release" on 01/04/02, 石塚圭樹 writes: >けいじゅ@日本ラショナルソフトウェアです. >>>|早速ですけど、Ruby本体のアーカイブに入るのを希望します。 >>>英語のドキュメント。 >> >>Toshのいんちき英語程度でよろしければ遠からぬうちに用意します。 > >そういう人がいてくれると嬉しいなぁ(^^;;; ということで, お願いします. とりあえず書いてみましたので、後ろにつけておきます。 日本語版の対訳になっていないのは仕様です。(^^;; 意味はそんなに遠くはずれていたりはしないはずです。たぶん。 # 英語のまともなひとのレビューを希望。 それと日本語版の方のインデントをちょっと修正しました。これも 後ろにつけておきます。 あと、ちょっと気になったのですが、 Forwardableの方では「モジュール メソッド」 SingleForwardableの方では「メソッド」となっているのはあえて使い分け ているのでしょうか? >= Forwardable > >クラスに対しメソッドの委譲機能を定義します. (...) >== モジュールメソッド (...) >= SingleForwardable > >オブジェクトに対し, メソッドの委譲機能を定義します. (...) >== メソッド --- Tosh Toshiro Kuwabara -- forwardable.rb $Release Version: 1.0 $ $Revision: 1.2 $ $Date: 1999/12/01 03:28:01 $ = Forwardable a Module to define delegations for selected methods to a class. == Usage Using through extending the class. class Foo extend Forwardable 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) == Methods --- Forwardable#def_instance_delegators(accessor, *methods) adding the delegations for each method of ((|methods|)) to accessor. --- Forwardable#def_instance_delegator(accessor, method, ali = method) adding the delegation for ((|method|)) to accessor. When you give optional argument ali, ali is used as the name of the delegation method, instead of ((|method|)). --- Forwardable#def_delegators(accessor, *methods) the alias of Forwardable#def_instance_delegators. --- Forwardable#def_delegator(accessor, method, ali = method) the alias of Forwardable#def_instance_delegator. = SingleForwardable a Module to define delegations for selected methods to an object. == Usage Using through extending the object. g = Goo.new g.extend SingleForwardable g.def_delegator("@out", :puts) g.puts ... == Methods --- SingleForwardable#def_singleton_delegators(accessor, *methods) adding the delegations for each method of ((|methods|)) to accessor. --- SingleForwardable#def_singleton_delegator(accessor, method, ali = method) adding the delegation for ((|method|)) to accessor. When you give optional argument ali, ali is used as the name of the delegation method, instead of ((|method|)). --- SingleForwardable#def_delegators(accessor, *methods) the alias of SingleForwardable#def_instance_delegators. --- SingleForwardable#def_delegator(accessor, method, ali = method) the alias of SingleForwardable#def_instance_delegator. -- forwatable.rb $Release Version: 1.0 $ $Revision: 1.2 $ $Date: 1999/12/01 03:28:01 $ = Forwardable クラスに対しメソッドの委譲機能を定義します. == 使い方 クラスに対してextendして使います. class Foo extend Forwardable 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) == モジュールメソッド --- Forwardable#def_instance_delegators(accessor, *methods) methodsで渡されたメソッドのリストをaccessorに委譲するようにします. --- Forwardable#def_instance_delegator(accessor, method, ali = method) methodで渡されたメソッドをaccessorに委譲するようにします. aliが引数とし て渡されたときは, メソッドaliが呼ばれたときには, accessorに対しmethodを 呼び出します. --- Forwardable#def_delegators(accessor, *methods) Forwardable#def_instance_delegatorsの別名です. --- Forwardable#def_delegator(accessor, method, ali = method) Forwardable#def_instance_delegatorの別名です. = SingleForwardable オブジェクトに対し, メソッドの委譲機能を定義します. == 使い方 オブジェクトに対してextendして使います. g = Goo.new g.extend SingleForwardable g.def_delegator("@out", :puts) g.puts ... == メソッド --- SingleForwardable#def_singleton_delegators(accessor, *methods) methodsで渡されたメソッドのリストをaccessorに委譲するようにします. --- SingleForwardable#def_singleton_delegator(accessor, method, ali = method) methodで渡されたメソッドをaccessorに委譲するようにします. aliが引数とし て渡されたときは, メソッドaliが呼ばれたときには, accessorに対しmethodを 呼び出します. --- SingleForwardable#def_delegators(accessor, *methods) SingleForwardable#def_singleton_delegatorsの別名です. --- SingleForwardable#def_delegator(accessor, method, ali = method) SingleForwardable#def_singleton_delegatorの別名です.