From: Jason Roelofs Date: 2008-03-13T04:54:59+09:00 Subject: Re: Get OpenStruct attributes Given this setup: >> require 'ostruct' => false >> o = OpenStruct.new => # >> o.field = "this" => "this" >> o.fold = "that" => "that" >> o => # The "nice" way: >> o.methods - Object.methods - OpenStruct.instance_methods => ["fold", "fold=", "field", "field="] Or maybe go one more level, to kick out the attr= methods: (o.methods - Object.methods - OpenStruct.instance_methods).reject {|method| method =~ /=$/ } The "dirty" way: >> o.instance_variable_get("@table") => {:field=>"this", :fold=>"that"} Jason On Wed, Mar 12, 2008 at 3:04 PM, Ed Hames wrote: > Dear rubyists, > > What's the best way to get the list of attributes of an OpenStruct? > > Thanks in advance, > Edgardo > >