ruby picture

RCR 111: IO subclass for string

Submitted by anonymous (Wed Jun 26 18:06:18 UTC 2002)

Abstract

This is a legacy RCR from Ruby Garden, submitted by anonymous. Matz has declared these RCRs obsolete, and asked that their authors resubmit them in the new format.

I'd like to see a sub-class of IO that used a String for internal storage.

Problem

(RCR imported from old format)

Proposal

Something like:
a = IOString::new
a.puts "Hello, world!"
str = a.string # maybe a.to_s ?
puts str
b = IOString::open(str)
str = b.gets
puts str

I use this kind of structure to store parts of files in place, for parsing later... I created my own class to do this (which was easy, since I knew exactly which methods of IO I'd be talking to), but it seems like something that belongs in the standard library.

Analysis

(RCR imported from old format)

Implementation

(RCR imported from old format)
ruby picture
Comments Current voting

Try StringIO (matz, 2002-06-26 19:48:19)

..from RAA. It is bundled with 1.7 CVS snapshot.

matz.


Strongly opposed 0
Opposed 0
Neutral 0
In favor 0
Strongly advocate 0
ruby picture
If you have registered at RCRchive, you may now sign in below. If you have not registered, you may sign up for a username and password. Registering enables you to submit new RCRs, and vote and leave comments on existing RCRs.
Your username:
Your password:

ruby picture

Powered by .