From: William Djaja Tjokroaminata Date: 2002-09-27T03:15:57+09:00 Subject: Re: object attributes list Hi, 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 ============================================================================ ajksharma wrote: > HI, > I have a Object > Customer > .Customerid="Alfki" > .city = "Belin" > etc > I want to get a list of these attributes and their values, > Possibly in a hash form. > Customers = { "Customerid" => "Alfki", > "city" => "Belin" > } > Regards > Ajay