From: Gareth Adams Date: 2007-02-27T00:57:30+09:00 Subject: Re: symbol to true object > > > Or > > > > > class Symbol > > > def to_bool > > > if to_s.eql?("true") > > > > if eql?(:true)> true > > > elsif to_s.eql?("false") > > > > elsif eql?(:false)> false > > > else > > > raise ArgumentError > > > end > > > end > > > end > > > > > :true.to_bool => true > > > :false.to_bool => false > > > :nothing.to_bool => ArgumentError class Symbol def to_bool case to_s when "true" then true when "false" then false else raise ArgumentError end end end