るりまサーチ (Ruby 2.2.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.034秒)
トップページ > バージョン:2.2.0[x] > クエリ:IO[x] > クエリ:write[x] > クエリ:close[x] > ライブラリ:stringio[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io readlines
  4. io each_line
  5. io each

クラス

キーワード

検索結果

StringIO#close_write -> nil (45613.0)

自身に対する書き込みを禁止します。

自身に対する書き込みを禁止します。

@raise IOError 自身がすでに書き込み不可だった場合に発生します。

StringIO#closed_write? -> bool (45610.0)

自身に対する書き込みが禁止されているなら true を返します。そうでない場合は、false を返します。

自身に対する書き込みが禁止されているなら true を返します。そうでない場合は、false を返します。

StringIO#closed? -> bool (27409.0)

自身が既に close されていた場合に true を返します。そうでない場合は、false を返します。

...身が既に close されていた場合に true を返します。そうでない場合は、false を返します。

//emlist[例][ruby]{
require "stringio"
sio = StringIO.open("hoge")
p sio.closed? # => false
sio.close_read
p sio.closed? # => false
sio.close_write
p sio.closed? # => true
//}...

StringIO (18163.0)

文字列に IO と同じインタフェースを持たせるためのクラスです。

...です。

//emlist[例][ruby]{
require "stringio"
sio = StringIO.new("hoge", 'r+')
p sio.read #=> "hoge"
sio.rewind
p sio.read(1) #=> "h"
sio.write("OGE")
sio.rewind
p sio.read #=> "hOGE"
//}

=== 例外
StringIO
オブジェクトは大抵の場合 IO...
...オブジェクトと同じ例外を発生させます。
例えば次の例では write は IOError を発生させます。

//emlist[例][ruby]{
require "stringio"
sio = StringIO.new("hoge")
sio.close
sio.write("a")
# => in `write': not opened for writing (IOError)
//}...