Sha256: db716c801ddfaf6440c7121694e1d920c9af97dd6ca2b1abaf5f752d76204466
Contents?: true
Size: 380 Bytes
Versions: 3
Compression:
Stored size: 380 Bytes
Contents
module Kernel # # Captures the given stream and returns it: # # stream = capture(:stdout) { puts 'Cool' } # stream # => "Cool\n" def capture(stream) begin stream = stream.to_s eval "$#{stream} = StringIO.new" yield result = eval("$#{stream}").string ensure eval("$#{stream} = #{stream.upcase}") end result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pointrb-0.1.2 | spec/support/capture.rb |
pointrb-0.1.1 | spec/support/capture.rb |
pointrb-0.1.0 | spec/support/capture.rb |