From: Joey Gibson Date: 2003-08-22T21:11:53+09:00 Subject: Re: Wrapping ENV On Fri, 22 Aug 2003 07:15:33 +0900, "Sean O'Dell" wrote: ||| That's pretty useful! Why not generalize it though: ||| ||| class Record ||| def initialize(source) ||| source.to_hash.each do |name, value| ||| method_name = name.downcase ||| define_method(method_name) { source[name] } Why not make use of method_missing instead of defining methods for each existing variable? The following code will work for existing variables as well as let you add new ones. class MyEnv def method_missing(symbol, *args) str = symbol.id2name if args.length == 0 ENV[str] else ENV[str] = args[0].to_s end end end e = MyEnv.new e.foo 23 e.foo => 23 e.path(e.path + "/tmp") e.path => "...:/tmp" -- Dean saor, dean saor an spiorad. Is seinn d'orain beo. http://www.joeygibson.com http://www.joeygibson.com/blog/life/Wisdom.html