From: unbewusst.sein@... (=?ISO-8859-1?Q?Une_B=E9vue?=) Date: 2010-06-03T00:15:05+09:00 Subject: Re: having a class method called only one time ? Jes�s Gabriel y Gal�n wrote: > I think it looks cleaner using the idiom Tony described: > > class HFSFile > def host_ip > @host_ip ||= host_ip_get > end > private > > def host_ip_get > $stderr.puts "'host_ip_get' was called!" # called 1 time for 2 > instantiations. > host_ip = '' > while host_ip.empty? > host_ip = `curl -s http://whatismyip.org`.chomp > end > host_ip > end > end i do agree, it's cleaner and much more rubyish, thanks ! -- � Les faiblesses des hommes font la force des femmes. � (Voltaire)