Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory streams in Ruby?

Tags:

ruby

Does ruby have memory streams somewhere that I'm missing? It looks like IO is just for file-backed streams... I'm hoping for something similar to System.IO.MemoryStream in .NET?

like image 200
Brad Heller Avatar asked May 09 '11 00:05

Brad Heller


2 Answers

Are you after something like StringIO?

like image 71
Andrew Grimm Avatar answered Oct 19 '22 19:10

Andrew Grimm


There are pipes:

r, w = IO.pipe
w.puts("Hello World")
puts r.gets
like image 23
Theo Avatar answered Oct 19 '22 18:10

Theo