From: Ryan Victory Date: 2013-02-28T07:10:19+09:00 Subject: Re: Object track llist for a particular class. Interesting, try this instead: Hash[local_variables.map {|k| [k,eval(k.to_s)]}].inspect.scan(/[{ ,]\:([^=]+)\=/).flatten -Ryan On 2/27/13 3:56 PM, Xavier R. wrote: > Ryan Victory wrote in post #1099432: >> Hans, >> Hash[local_variables.map {|k| [k,eval(k.to_s)]}].inspect.scan(/(?:\{| >> )\:([^=]+)\=/).flatten >> >> Love U Ruby, that should return for you the instances in the form of >> ["a","b"] in your example. >> >> -Ryan > It gives the below: > >>> class Test >>> end > => nil >>> foo = Test.ne > NoMethodError: undefined method `ne' for Test:Class > from (irb):12 > from /usr/bin/irb:12:in `
' >>> foo = Test.new > => # >>> bar = Test.new > => # >>> Hash[local_variables.map {|k| [k,eval(k.to_s)]}].inspect.scan(/(?:\{| > )\:([^=]+)\=/).flatten > => ["bar"] > > Not ["foo","bar"] >