StringIO

IO と同じインタフェースを持った文字列クラス。

スーパークラス:

クラスメソッド:

StringIO.new([string[, mode]])
StringIO.open([string[, mode]])
StringIO.open([string[, mode]]) {|io| ... }

StringIO オブジェクトを生成します。

require 'stringio'

io = StringIO.new("foo")
p io.getc       # => 102
p io.pos        # => 1
p io.size       # => 3
io << "bar"
p io.size       # => 4
io.rewind
p io.gets       # => "fbar"

メソッド:

string

IOバッファ(文字列)を返します。

string= buf

IOバッファを buf に変更し、buf を返します。これ以前の バッファは捨てられます。StringIO は読み書き両用になりますが、 bufnil の場合は、StringIO への読み書きは禁止されます。

reopen

例外 NotImplementedError が発生します。

lineno
lineno=
binmode

何もせずに self を返します。

close
close_read
close_write
closed?
closed_read?
closed_write?
eof
eof?
fcntl

例外 NotImplementedError が発生します。

flush

何もせずに self を返します。

fsync

何もせずに 0 を返します。

pos
pos=
rewind
seek
sync

何もせずに 0 を返します。

sync= bool

何もせずに bool を返します。

tell
path

inspect と同じです。

each
each_byte
each_line
getc
ungetc
readchar
gets
readline
readlines
read
sysread
write
self <<
print
printf
putc
puts
syswrite

write と同じです。

isatty
tty?

何もせず false を返します。

pid
fileno

何もせず nil を返します。

size
length
truncate