8

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?

osgx
  • 90,338
  • 53
  • 357
  • 513
Brad Heller
  • 1,551
  • 5
  • 18
  • 29
  • Is this a duplicate of http://stackoverflow.com/questions/10323/why-doesnt-ruby-have-a-real-stringbuffer-or-stringio ? – Andrew Grimm May 09 '11 at 03:54

2 Answers2

8

Are you after something like StringIO?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
6

There are pipes:

r, w = IO.pipe
w.puts("Hello World")
puts r.gets
Theo
  • 131,503
  • 21
  • 160
  • 205
  • I think this is pretty much what I'm after...I don't really want text data only, and this looks like it's what I need! Thanks! – Brad Heller May 11 '11 at 06:36