Return to Snippet

Revision: 5540
at March 13, 2008 18:38 by cczona


Initial Code
require 'stringio'

sio=StringIO.new('acts like a file')
puts sio.pos # => 0
sio.pos= sio.length - 4
puts sio.read # => 'file'

Initial URL
http://whytheluckystiff.net/articles/rubyOneEightOh.html

Initial Description
This is handy for testing, when you need to simulate an open file or open URI.  Why, and the Pickaxe book, have better examples

Initial Title
make Ruby strings behave like files

Initial Tags
url, file, ruby

Initial Language
Ruby