From: Wiebe Cazemier Date: 2006-04-14T07:32:48+09:00 Subject: Re: Question mark in attr_* On Thursday 13 April 2006 19:23, Patrick Hurley wrote: > 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 I will give this a go tomorrow (it's bedtime now...). Should work pretty well. Thanks.