On 4/13/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote:
> On Fri, 14 Apr 2006, Patrick Hurley wrote:
>
> > On 4/13/06, Wiebe Cazemier <halfgaar / gmx.net> wrote:
> >> Hi,
> >>
> >> Methods which return booleans end with a question mark, by convention. But how
> >> about boolean attributes (attr_[reader, accessor, writer])? Saying
> >> "attr_reader :variable?" won't work. I find it rather strange when you have to
> >> access boolean attributes without the question mark, but the methods with the
> >> question mark.
> >>
> >>
> >>
> >
> > As ruby does not have data types, the onus is on the developer to
> > spell out that she/he wants such an accessor. So add this to your
> > program:
> >
> > class Module
> > def battr_reader(sym, *more)
> >   battr_reader(*more) unless more.empty?
> >   define_method("#{sym}?") { !!instance_variable_get("@#{sym}") }
> > end
> > end
> > Then you can add a battr_reader to any class...
> > pth
>
> or just use
>
>    attr_reader 'variable?'
>
> ;-)
>
> -a
> --
> be kind whenever possible... it is always possible.
> - h.h. the 14th dali lama
>
>

That does not work for me, is there a trick?

pth