The following does what you want in one pass:
INP =3D ["DEBUGG=3Dtrue", "auto=3Dtrue", "dummy=3Dempty",
"files=3D/Users/yvon/MacSOUP_proxad/proxad, /Users/yvon/MacSOUP_eclipse/=20=
eclipse, /Users/yvon/MacSOUP_news.individual.net/individual"]
@h =3D {}
INP.each do |a|
k,v =3D a.split("=3D")
case v
when /true/ then @h[k] =3D true
when /false/ then @h[k] =3D false
when /,[\s]*/ then @h[k] =3D v.split(/,[\s]*/)
else @h[k] =3D v
end
end
It is easily extend to other cases if necessary. Whether or not it is =20=
better or more Ruby-ish is for you to decide.
Hope this helps.
Regards, Morton
On Aug 3, 2006, at 6:35 AM, Une b=E9vue wrote:
> on Mac OS X using launchd i'm only able to pass args like that :
>
> ["DEBUGG=3Dtrue", "auto=3Dtrue", "dummy=3Dempty",
> "files=3D/Users/yvon/MacSOUP_proxad/proxad,
> /Users/yvon/MacSOUP_eclipse/eclipse,
> /Users/yvon/MacSOUP_news.individual.net/individual"]
>
>
> then for the time being i do :
>
> @h=3D{}
> $*.each {|a| k,v=3Da.split("=3D"); @h[k]=3Dv}
>
> and, afterwards :
>
> @h['DEBUGG']=3D(@h['DEBUGG']=3D=3D"true")
> for bool, and for array :
>
> @h['files']=3D@h['files'].split(", ")
>
> i don't like that because i have to know, a priori, the types and =20
> names
> of the args.
>
> a better solution more rubyish ???
|