On Feb 3, 4:45=A0am, Ryan Davis <ryand-r... / zenspider.com> wrote:
> On Feb 2, 2009, at 18:34 , mwlang88 wrote:
>
> >> in other words, why would I want to add 250 lines of dependency code
> >> where 0 seems to suffice?
>
> > As always, depends on where you want to go with it. =A0For me, I wanted
> > to catch typos immediately much like a compiled language might.
>
> immediately? how? you can't (afaik) do better than a runtime error of =A0
> some kind. No different than a const_missing/NameError that you're =A0
> going to get with a typo'd constant name.
>
> > I also wanted to associate a display value with a symbol.
>
> #to_s ? #to_html ? #to_whatever ? Maybe I'm not getting your point on =A0
> this one.
>
> > And I also wanted to have that be enumerable so I can populate a =A0
> > dropdown list or emit radio button groups and checkboxes.
>
> Arrays are already enumerable.
>
> =A0 =A0 =A0# actual code from png.rb:
> =A0 =A0 =A0Background =3D Color.from 0x00000000, "Transparent"
> =A0 =A0 =A0Black =A0 =A0 =A0=3D Color.from 0x000000FF, "Black"
> =A0 =A0 =A0Blue =A0 =A0 =A0 =3D Color.from 0x0000FFFF, "Blue"
> =A0 =A0 =A0Brown =A0 =A0 =A0=3D Color.from 0x996633FF, "Brown"
> =A0 =A0 =A0Bubblegum =A0=3D Color.from 0xFF66FFFF, "Bubblegum"
> =A0 =A0 =A0Cyan =A0 =A0 =A0 =3D Color.from 0x00FFFFFF, "Cyan"
> =A0 =A0 =A0Gray =A0 =A0 =A0 =3D Color.from 0x7F7F7FFF, "Gray"
> =A0 =A0 =A0Green =A0 =A0 =A0=3D Color.from 0x00FF00FF, "Green"
> =A0 =A0 =A0Magenta =A0 =A0=3D Color.from 0xFF00FFFF, "Magenta"
> =A0 =A0 =A0Orange =A0 =A0 =3D Color.from 0xFF7F00FF, "Orange"
> =A0 =A0 =A0Purple =A0 =A0 =3D Color.from 0x7F007FFF, "Purple"
> =A0 =A0 =A0Red =A0 =A0 =A0 =A0=3D Color.from 0xFF0000FF, "Red"
> =A0 =A0 =A0White =A0 =A0 =A0=3D Color.from 0xFFFFFFFF, "White"
> =A0 =A0 =A0Yellow =A0 =A0 =3D Color.from 0xFFFF00FF, "Yellow"
>
> so it would be trivial to do:
>
> =A0 =A0Colors =3D [...all of the above...]
>
> ..
> options_from_collection_for_select(Color::Colors, :to_hex, :name)
>
> > Not every case calls for Elemental, but I find that it heightens my
> > code's clarity and maintainability and felt it worthy to release to
> > public domain.
>
> Granted, the doco you have up on github is a tad on the light side, =A0
> but I just don't see it. Ruby seems to provide pretty good mechanisms =A0
> for everything you're trying to solve.

This is some interesting stuff and you have just shown me a technique/
use of arrays I haven't encountered yet.  Looks like I'm going to have
to take myself back to school here.

Michael