From: ajksharma@... (ajksharma) Date: 2002-09-27T19:21:45+09:00 Subject: Re: object attributes list Hi, Thanks , it works. Regards Ajay > I think the key to what you want to accomplish it the > Object#instance_variables method. Here is an example; I am sure other > people can write better Ruby code: > > class Customer > attr_reader :Customerid, :city > def initialize > @Customerid = 123 > @city = 'abc' > end > end > > c = Customer.new > > hash = {} > c.instance_variables.each do |var| > var = var.slice (1...(var.length)) > val = eval "c.#{var}" > hash[var] = val > end > hash.each_key {|key| puts "\"#{key}\" => \"#{hash[key]}\""} > > Regards, > > Bill >