From: "akira yamada / やまだあきら" Date: 2002-06-12T20:33:34+09:00 Subject: [ruby-dev:17405] Re: making net/*.rb grok URI >>>>> In [ruby-dev : No.15937] >>>>> Minero Aoki wrote: > uri.host_port みたいのを作ってもらうというのはダメですかね。 > あるいは uri.select(:host,:port) とか。 なんか、今さらなんですが実装してみました。 実はもういらなくなってるとかってことはありますかね? (^_^; # いらなくなっていなければroughの方に入れてみようと思っていますが…。 Index: uri/generic.rb =================================================================== RCS file: /src/rough/lib/uri/uri/generic.rb,v retrieving revision 1.14 diff -u -r1.14 generic.rb --- uri/generic.rb 2002/04/03 09:12:23 1.14 +++ uri/generic.rb 2002/06/12 11:31:24 @@ -1085,6 +1085,20 @@ end =begin +--- URI::Generic#select(*components) +=end + def select(*components) + components.collect do |c| + if component.include?(c) + self.send(c) + else + raise ArgumentError, + "expected of components of #{self.type} (#{self.type.component.join(', ')})" + end + end + end + +=begin =end def inspect sprintf("#<%s:0x%x URL:%s>", self.type.to_s, self.id, self.to_s) -- やまだあきら / プライベート - akira@arika.org お仕事 / Vine Caves, Ltd. - akira@vinecaves.com 日本のLinux情報, 日本Linux協会 - akira@linux.or.jp