Posted By

cczona on 03/13/08


url file testing ruby io String open uri open-uri stringio

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


make Ruby strings behave like files

 / 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

  1. require 'stringio'
  3.'acts like a file')
  4. puts sio.pos # => 0
  5. sio.pos= sio.length - 4
  6. puts # => 'file'

Report this snippet  

You need to login to post a comment.