From: William James Date: 2007-10-09T09:00:06+09:00 Subject: Re: The old File.rename not working again. . . . On Oct 8, 5:17 pm, Simon Krahnke wrote: > * William James (22:01) schrieb: > > >>| File.rename(file, "#{file}.eps") if /%!PS-Adobe/ =~ File.open {|file| f.gets} > > > I think that should be > > > File.rename(file, "#{file}.eps") if /%!PS-Adobe/ =~ File.open(file){| > > f| f.gets} > > Yeah, I correct one error and repeat another. > > > More terse: > > > File.rename(file, "#{file}.eps") if /%!PS-Adobe/ =~ IO.read(file,10) > > That's a violation of the DRY principle. > > Define PS = '%!PS-Adobe' then > > | File.rename(file, "#{file}.eps") if IO.read(file, PS.length)[PS] That's a violation of common sense. '%!PS-Adobe' isn't going to change, and therefore 10 won't need changing. Unjustified code inflation and a superfluous temporary variable. Furthermore, why say ".length" when you can say ".size"? You have a perverse, pronounced propensity for prolixity.