Another option to look at is StringIO, so that you keep IO-like methods 
such as "puts". You could also wrap _erbout this way:

$ irb --simple-prompt
>> require 'erb'
=> true
>> require 'stringio'
=> true
>> ERB.new(<<'EOS').result(binding)
<% out = StringIO.new(_erbout) %>
<%
  3.times do
    out.puts rand
  end
%>
EOS
=> "0.761865648122361\n0.792800150151016\n0.683615203721222\n\n"
>> 
-- 
Posted via http://www.ruby-forum.com/.