On Oct 8, 5:17 pm, Simon Krahnke <overl... / gmx.li> wrote:
> * William James <w_a_x_... / yahoo.com> (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.