Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: "Jeroen v." Newsgroups: comp.lang.ruby Subject: Set attribute of superclass dinamically Date: Sun, 24 Apr 2011 09:29:33 -0500 Organization: Service de news de lacave.net Lines: 22 Message-ID: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303655397 11751 65.111.164.187 (24 Apr 2011 14:29:57 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sun, 24 Apr 2011 14:29:57 +0000 (UTC) X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382123 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3436 I have the following code class foo price_per_liter = 1 price module bar def set_price val self.price_per_liter = val end end end In this way I can succesfully set the price per liter of the class. How can I make it dunamically, so I can also set the attribute 'price'? I tried instance_variable_set(@variable, val), but that doesn't work. Probably because the variables of the class 'foo' and the module 'bar' lives independent of each other. -- Posted via http://www.ruby-forum.com/.