/ Published in: Ruby
This is handy for testing, when you need to simulate an open file or open URI. Why, and the Pickaxe book, have better examples
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
require 'stringio' sio=StringIO.new('acts like a file') puts sio.pos # => 0 sio.pos= sio.length - 4 puts sio.read # => 'file'
URL: http://whytheluckystiff.net/articles/rubyOneEightOh.html