From: Gregory Brown Date: 2008-08-03T03:20:43+09:00 Subject: Re: Back on the List - Two questions On Sat, Aug 2, 2008 at 2:12 PM, list. rb wrote: > It's been a while but it feels good to be back. > > I have a quick question for the group: > > Given the following: > > content = [ > ["something special a", "ok cool a", "tahsnk a"], > ["something specccccccccial a", "ok cooooool a", "tahsnk a"] > ] > content.each {|i| > puts i.join("\t") > } > #something special a ok cool a tahsnk a > #something specccccccccial a ok cooooool a tahsnk a > > I would like to print this out as such: > something special a ok cool a tahsnk a > something specccccccccial a ok cooooool a tahsnk a > > I remember seeing a module or example like this somewhere.. Any ideas? I was > thinking it was pretty print at first but after looking, I guess not? Well, it's a bit like killing a mosquito with a bazooka, but you could use Ruport for this: >> require "rubygems" => true >> require "ruport" => true >> content = [ ?> ["something special a", "ok coola", "tahsnk a"], ?> ["something speccccccccccccial a", "ok cooool a", "tahsnk a"] >> ] => [["something special a", "ok coola", "tahsnk a"], ["something speccccccccccccial a", "ok cooool a", "tahsnk a"]] >> puts Table(:data => content) +---------------------------------------------------------+ | something special a | ok coola | tahsnk a | | something speccccccccccccial a | ok cooool a | tahsnk a | +---------------------------------------------------------+ But if you don't want the decorations, you'd need to tweak things. Feel free to take a look at the (not exactly pretty) source and re-use whatever code you'd like: http://github.com/ruport/ruport/tree/master/lib/ruport/formatter/text.rb -greg -- Killer Ruby PDF Generation named after a magnificent sea creature: http://github.com/sandal/prawn | Non-tech stuff at: http://metametta.blogspot.com