From: Jean-Hugues ROBERT Date: 2002-05-11T19:09:00+09:00 Subject: Re: cgi params api Hello, At 18:16 11/05/2002 +0900, you wrote: >On Sat, May 11, 2002 at 06:28:45AM +0900, > Jean-Hugues ROBERT wrote: > > > Yes ! That works. I learned it recently ! You basically > > *.extend* "value" so that it now have a singleton method called > > .values(). Cool, isn't it ? > >cgi["name"].values >cgi.params["name"] > >same length ;-) Well... I was comparing .values() versus .multiple()... > > I may still prefer cgi.name.values however (if I were to think about > > it more). > >It limits identifire. > >cgi.query_string, cgi.path_info, cgi.script_name, ... > >cgi["query_string"] # ok >cgi.query_string # bad Wakou Aoyama I agree. However I am developing a SIP tool where I handle this differently. In SIP, names can be spelled in many different ways, case is insensitive and there is even a "Compact" form for some common names. So I ended up handling these names in what I called a "Cannonical" form. As a result I made it so that the "Cannonical" name would be a Ruby Symbol. The Rule is simple: 1) Get name 2) Uppercase it 3) Lookup in some hash to see if this is a valid name 4) The hash associate the canonical name to the Uppercase name You initialize the hash using whatever rule fits your style. For me: 1) Lower case everything 2) Break name in space separated words 3) Capitalize each word 4) Join them 5) Make a Symbol As a result: Content-Length becomes :ContentLength param-string would become ParamString If you don't like CamelCase, just change the rule: Content-Length becomes content_length ... What you get: 1) Reduced impedance mismatch between Ruby and the protocol 2) Higher speed (Symbol being faster than String) Yours, Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17