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