Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Avoid trucate column at printing table
Marc Pou
11/29/2008 11:23:00 PM
Hi,
I've a table defined as the code below:
table = Table(%w[Page Position Domain URL Description])
And I fill it as you can see:
table << [iPage, iPosition, sDomain, sURL, sDescription]
When I finish I want output the table doing this:
myfile.puts table.to_s
but the content of the columns is too large and I get this:
+----------------------------------------------------------------------------->>
| Page | Position | Domain | >>
+----------------------------------------------------------------------------->>
| 1 | 1 | www.miltrabajos.com |
http://www.miltrabajos.com/O...
| 1 | 2 | www.miltrabajos.com |
http://www.miltrabajos.com/C...
How can I avoid the trucate of the table?
Thanks in advance!
--
Posted via
http://www.ruby-...
.
2 Answers
Brian Candler
11/30/2008 4:46:00 PM
0
As a guess - because you don't actually say it yourself - this is a
question about the Ruport library, right?
I remember this being a bit of a pain to make do what I wanted.
(Digs through old code). Oh yes, in a custom Renderer you can do
options { |o| o.ignore_table_width = true }
However I'm not sure if it's possible to this with the default renderer
for a table (i.e. Table#to_s as you're doing above). Possibly you could
fake the method which works out the screen size to give a much larger
table width.
Ruport has its own google group - you'd probably be better off asking
there.
HTH,
Brian.
--
Posted via
http://www.ruby-...
.
Marc Pou
12/1/2008 9:40:00 AM
0
Finally I've find the solution myself
I'm newbie with Ruby and Ruport. The solution is to call de "to_text"
method of the table instead of "to_s" and use the ":ignore_table_width"
attribute.
myfile.puts table.to_text( :ignore_table_width => true, :width => 200)
I read this option in the documentation, but I didn't known how to use
it.
Now this works fine and produces this output:
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Page | Position | Domain | URL | Description |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | 1 | barcelona.campusanuncios.com |
http://barcelona.campusanuncios.com/detempleo-1892452216X-Oferta-de-Barc...
| Oferta de Empleo Primer empleo como programador Barcelona Espað?? |
| 1 | 2 | empleo.trovit.es |
http://empleo.trovit.es/ofertas-empleo/programador-php...
| programador php barcelona - Trovit Empleo |
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Avoid trucate column at printing table
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password