From: Sean O'Halpin Date: 2008-05-23T22:07:40+09:00 Subject: Re: Help extending Hash to allow hexadecimal encoded keys (problem with "Delegator") On Fri, May 23, 2008 at 11:21 AM, Iņaki Baz Castillo wrote: > 2008/5/23, Heesob Park : > >> def []=(k,v) >> k = CiString.new(k) if String === k >> __getobj__[k] = v >> end >> >> def [](k) >> k = CiString.new(k) if String === k >> >> __getobj__[k] >> end >> >> def find(ifnone = nil,&blk) >> __getobj__.find(ifnone,&blk) >> end >> >> def find_all(&blk) >> __getobj__.find_all(&blk) >> end > > > > Thanks a lot, but it gives me errors: > > @uri > => {"T%61g"=>"%61liCE", "qwe"=>"qqqqqqqqqqQQQQQQQQQQQ"} > > @uri.find {|e| e[0] == "qwe" } > NoMethodError: undefined method `string' for "qwe":String > from uri.rb:72:in `==' > from (irb):6 > from (irb):6:in `find' > from uri.rb:98:in `each' > from uri.rb:98:in `find' > from uri.rb:98:in `find' > from (irb):6 > > > Unfortunatelly I have no idea of how to debug it since I don't > understand how exactly Delegator works. Any tip please? > > Really thanks a lot. > > > > -- > Iņaki Baz Castillo > > I think you want something like: def eql?(s) unescape(string.downcase).eql? unescape(s.to_s.downcase) end with Park's changes so that: uri = UriParametersHash.new uri["T%61G"] = "lololo" uri # => {"T%61G"=>"lololo"} uri.find{|e| e[0] == "tag"} # => ["T%61G", "lololo"] Regards, Sean