L
Lyle Johnson
------=_Part_12529_21253768.1139514155340
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I'm looking to make an API change for some methods in FXRuby and would
appreciate some suggestions about how to improve them. The pattern shows up
in several places in the code, but it always boils down to some widget
attribute that can have a combination of bit-flags. For example, the 4-way
splitter window can be configured to expand only its top-left pane:
splitter1.expanded =3D TOP_LEFT
or to expand both the top left and top right panes:
splitter2.expanded =3D TOP_LEFT | TOP_RIGHT
And to check whether, say, the BOTTOM_LEFT pane is expanded:
(splitter3.expanded & BOTTOM_LEFT) !=3D 0
Now, what I'm thinking of doing is replacing the symbolic constants with
Ruby symbols, and doing something like this instead:
splitter1.expandtop_left)
splitter2.expandtop_left, :top_right)
and then having checks like:
splitter3.expanded? :bottom_left
I think that in order to "turn off" one of those bits, I'm probably also
going to need to add something like:
splitter4.unexpandbottom_right)
Now, the question is, is there some existing pattern in Ruby that this
reminds you of? In other words, what is the Ruby Way to handle this kind of
setting?
Thanks in advance for your suggestions!
Lyle
------=_Part_12529_21253768.1139514155340--
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I'm looking to make an API change for some methods in FXRuby and would
appreciate some suggestions about how to improve them. The pattern shows up
in several places in the code, but it always boils down to some widget
attribute that can have a combination of bit-flags. For example, the 4-way
splitter window can be configured to expand only its top-left pane:
splitter1.expanded =3D TOP_LEFT
or to expand both the top left and top right panes:
splitter2.expanded =3D TOP_LEFT | TOP_RIGHT
And to check whether, say, the BOTTOM_LEFT pane is expanded:
(splitter3.expanded & BOTTOM_LEFT) !=3D 0
Now, what I'm thinking of doing is replacing the symbolic constants with
Ruby symbols, and doing something like this instead:
splitter1.expandtop_left)
splitter2.expandtop_left, :top_right)
and then having checks like:
splitter3.expanded? :bottom_left
I think that in order to "turn off" one of those bits, I'm probably also
going to need to add something like:
splitter4.unexpandbottom_right)
Now, the question is, is there some existing pattern in Ruby that this
reminds you of? In other words, what is the Ruby Way to handle this kind of
setting?
Thanks in advance for your suggestions!
Lyle
------=_Part_12529_21253768.1139514155340--