```Ruby Reports. Ruport. Check it out.

On Aug 22, 2007, at 7:21 AM, Peter Versteegen wrote:

> # Hi,
>
> # I need some help in simplefying my life
> # I need to create lots of tables from arrays and I need to provide
> # each of the columns with a heading.  For eample, I have
> # two headings "a-value" and "b-value" specified as follows:
> a = ["a-value", "b-value"]
> b = [10, 10]
> # The array b contains the width of the field, so that I get:
> #   a-value   b-value
> # Two ways to do this are as follows:
> puts "#{'a-value'.rjust(10)}#{'b-value'.rjust(10)}"
> puts "#{a[0].rjust(b[0])}#{a[1].rjust(b[1])}"
>
> # which is difficult to debug, so that I'm looking for
> # a simpler process, specificaly by writing a function.
> # The following one works:
>
>   x.length.times do |i|
>     print "#{x[i].rjust(n[i])}"
>   end
>   print "\n\n"
> end
>
> puts
>
> # But this approach doesn't.  Why not? Are there other ways to make
> this simpler?
>
>   s = ""
>   x.length.times do |i|
>     s = s + "\#{\'" + x[i] + "\'.rjust(" + n[i].to_s + ")}"
>   end
>   p s
>   print s
>   puts s
>   return s
> end
>
>
>
> # Thanks ahead. (NOTE: This file can be run from TextMate)
>
>
>
> Peter Versteegen
> pversteegen / gcnetmail.net
>
>
>
>

---------------------------------------------------------------|
~Ari
"I don't suffer from insanity. I enjoy every minute of it" --1337est
man alive

```