Skip to content

Commit 7eaf2e0

Browse files
committed
Make the default rendering destination $stdout
1 parent 7335d6b commit 7eaf2e0

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/unicode_plot/plot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def annotate_row!(loc, row_index, value, color: :normal)
103103
end
104104
end
105105

106-
def render(out, newline: true)
106+
def render(out=$stdout, newline: true)
107107
Renderer.render(out, self, newline)
108108
end
109109

test/test-plot.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'stringio'
2+
3+
class TestPlot < Test::Unit::TestCase
4+
sub_test_case("#render") do
5+
test("render to $stdout when no arguments") do
6+
sio = StringIO.new
7+
UnicodePlot.barplot(data: {a: 23, b: 37}).render(sio)
8+
9+
begin
10+
save_stdout, $stdout = $stdout, StringIO.new
11+
UnicodePlot.barplot(data: {a: 23, b: 37}).render
12+
assert do
13+
sio.string == $stdout.string
14+
end
15+
ensure
16+
$stdout = save_stdout
17+
end
18+
end
19+
end
20+
end

0 commit comments

Comments
 (0)