Output DBI::Utils::TableFormatter.ascii to something other than STDOUT

How would I output this to something other than STDOUT? Is there a
constant I could replace for STDOUT to return the table to the tbl variable?

tbl = DBI::Utils::TableFormatter.ascii(col_names, rows, :center, :left,
1, 1, nil, STDOUT)

STDOUT is a global constant and is the initial value of IO global
variable $stdout. You can assign a different IO destination to $stdout
and use that instead of the constant STDOUT.

···

On Sunday, June 8, 2003, at 04:31 PM, culley harrelson wrote:

How would I output this to something other than STDOUT? Is there a
constant I could replace for STDOUT to return the table to the tbl
variable?

tbl = DBI::Utils::TableFormatter.ascii(col_names, rows, :center,
:left, 1, 1, nil, STDOUT)

Not just IO; output is appended using ‘<<’, so …

#
require ‘dbi’

col_names = %w{Won Lost Split}
rows =
5.times do
rows.push([won=rand(21), lost=rand(21-won), 20-won-lost])
end

DBI::Utils::TableFormatter.ascii(
col_names, rows, :center, :right, 1, 1, nil, tbl=“”)

^^^^^^

puts tbl
#</>

···

“Mark Wilson” mwilson13@cox.net wrote:

On Sunday, June 8, 2003, at 04:31 PM, culley harrelson wrote:

How would I output this to something other than STDOUT? Is there a
constant I could replace for STDOUT to return the table to the tbl
variable?

tbl = DBI::Utils::TableFormatter.ascii(col_names, rows, :center,
:left, 1, 1, nil, STDOUT)

STDOUT is a global constant and is the initial value of IO global
variable $stdout. You can assign a different IO destination to $stdout
and use that instead of the constant STDOUT.

±----±-----±------+

Won | Lost | Split |
±----±-----±------+
11 | 6 | 3 |
14 | 6 | 0 |
1 | 19 | 0 |
10 | 2 | 8 |
17 | 2 | 1 |
±----±-----±------+

daz