On 07.01.2008 19:06, Peter Bailey wrote: > Hello, > I need to do some simply computations on numbers pulled from a file. I > get the numbers using "scan." I've proven that I can get the numbers > alright. But, I need to do some division and multiplication on those > numbers, and, to be accurate, the numbers need to be floating numbers, > not integers. So, I've tried everything, or so I think, and Ruby keeps > complaining about my ".to_f" method. Can someone please tell me where > this .to_f should go? > Thanks, > Peter > > Dir.chdir("K:") > tifffile = File.basename(ARGV.to_s, ".*") + ".tif" > info = `tiffinfo #{tifffile}` > width = info.scan(/Image Width: ([0-9]{1,5})/) > depth = info.scan(/Image Length: ([0-9]{1,5})/) > res = info.scan(/Resolution: [0-9]{1,5}, ([0-9]{1,5}) pixels\/inch/) > > newwidth = width.to_f / 600 * 6 > newdepth = depth.to_f / 600 * 6 > > I get this from Ruby: > sizer.rb:10: undefined method `to_f' for [["5100"]]:Array > (NoMethodError) Your error is in using #scan (see the docs for details). This works better width = info[/Image Width: ([0-9]{1,5})/, 1].to_f ... Cheers robert