On 2002.05.14, Wakou Aoyama <wakou / fsinet.or.jp> wrote:
> Hi,
> 
> On Tue, May 14, 2002 at 03:39:26AM +0900,
>  Dossy wrote:
> 
> > cgi['name'] should return an object of type CGI::Param.
> > CGI::Param#inspect would return the first value it knows
> > of.
> 
> I thought so, too. but, is CGI::Param necessary?

Yes.

> cgi["key"] return first value as String.
> cgi.params return params as Hash.
> 
> foo(cgi["key"])
> 
> cgi.params["key"].each() do |value|
>   foo(value)
> end

The problem is when cgi["key"] wants to return an array.
Then "foo" == cgi["key"] will fail since you're comparing
a String to an Array.

So, I made CGI::Param subclass of String.  However, I defined
CGI::Param#to_a so if you want the array, you can have it and
then apply #each or whatever.

As convenience methods, I might suggest defining CGI::Param#each
etc.  Might be nice to have an ArrayLike mix-in instead of having
to define these methods, but I don't know how useful this is ...

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)