From: Ron Jeffries Date: 2002-01-13T13:47:23+09:00 Subject: Re: FileHandle (was: Re: Dir.entries have no home) On Sun, 13 Jan 2002 02:56:32 GMT, Massimiliano Mirra wrote: > def method_missing(method_id, *args, &block) > if @info.keys.include? method_id > # Read from @info hash > # > which = args.shift || :old > @info[method_id][which] > > elsif method_id.to_s =~ /(\w+)=/ and @info.keys.include?($1.intern) > # Assign to new values in @info hash > # > @info[$1.intern][:new] = args.shift > > elsif @stat.respond_to? method_id > # Act as a proxy for @stat > # > @stat.send(method_id, *args, &block) > > else > super > end OK, let's see what that first bit is about: > def method_missing(method_id, *args, &block) > if @info.keys.include? method_id > # Read from @info hash > # > which = args.shift || :old > @info[method_id][which] So if the method id is one of our keys, namely location mode path name uid or gid, then we return the old value of that key or the value indicated by the arg, i.e. it acts, for example, like def location (*args) @location[args.shift | :old] end if@ location was a hash with keys old/new. Is that right? If that's right, I might have thought that defining the methods would be more clear, and, not that it's important, more efficient. Am I missing the meaning, or not understanding the goodness of this approach? OK, it's bedtime here, I'll read more tomorrow ... Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.