るりまサーチ

最速Rubyリファレンスマニュアル検索!
96件ヒット [1-96件を表示] (0.098秒)

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

ライブラリ

キーワード

検索結果

IO#close -> nil (18163.0)

入出力ポートをクローズします。

...例外 IOError が発生しま
す。ガーベージコレクトの際にはクローズされていない IO ポートはクロー
ズされます。
self
がパイプでプロセスにつながっていれば、そのプロセスの終
了を待ち合わせます。


@
raise Errno::EXXX close...
...
@
raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "test")
f = File.open("testfile")
f.read # => "test"
f.close
# f.read # => IOError (すでに close しているので read できない)
//}

@
see IO#closed?, IO#close_read, IO#close...
...うと例外 IOError が発生しま
す。ガーベージコレクトの際にはクローズされていない IO ポートはクロー
ズされます。
self
がパイプでプロセスにつながっていれば、そのプロセスの終
了を待ち合わせます。

既に close されて...
...

@
raise Errno::EXXX close に失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "test")
f = File.open("testfile")
f.read # => "test"
f.close
# f.read # => IOError (すでに close しているので read できない)
//}

@
see IO#closed?, IO#close_read, IO#close_w...

IO#close_on_exec=(bool) (6173.0)

自身に close-on-exec フラグを設定します。

... close-on-exec フラグを設定します。

このフラグをセットすると exec(2) 時にそのファイルデスクリプタを
close
します。

@
see fcntl(2)
@
param bool 自身の close-on-exec フラグを true か false で指定します。

f = open("/dev/null")
f.close_on...
..._exec = true
system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory
f.closed? #=> false

@
see IO#close_on_exec?...

IO#closed? -> bool (6160.0)

self が完全に(読み込み用と書き込み用の両方が)クローズされている場合に true を返します。 そうでない場合は false を返します。

...
self
が完全に(読み込み用と書き込み用の両方が)クローズされている場合に true を返します。
そうでない場合は false を返します。

//emlist[例][ruby]{
IO
.write("testfile", "test")
f = File.new("testfile")
f.close # => nil
f.closed? # => tr...
...ue
f = IO.popen("/bin/sh","r+")
f.close_write # => nil
f.closed? # => false
f.close_read # => nil
f.closed? # => true
//}

@
see IO#close, IO#close_read, IO#close_write...

IO#reopen(path) -> self (150.0)

path で指定されたファイルにストリームを繋ぎ換えます。

...数を省略したとき self のモードをそのまま引き継ぎます。
IO
#pos, IO#lineno などはリセットされます。

@
param path パスを表す文字列を指定します。

@
param mode パスを開く際のモードを文字列で指定します。

@
raise Errno::EXXX 失敗し...
...ます。

//emlist[例][ruby]{
IO
.write("testfile", "This is line one\nThis is line two\n")
f1 = File.new("testfile", "a+")
f2 = File.new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") #...
...=> #<File:testfile>
f2.readlines # => ["This is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//}

@
see Kernel.#open...

IO#reopen(path, mode) -> self (150.0)

path で指定されたファイルにストリームを繋ぎ換えます。

...数を省略したとき self のモードをそのまま引き継ぎます。
IO
#pos, IO#lineno などはリセットされます。

@
param path パスを表す文字列を指定します。

@
param mode パスを開く際のモードを文字列で指定します。

@
raise Errno::EXXX 失敗し...
...ます。

//emlist[例][ruby]{
IO
.write("testfile", "This is line one\nThis is line two\n")
f1 = File.new("testfile", "a+")
f2 = File.new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") #...
...=> #<File:testfile>
f2.readlines # => ["This is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//}

@
see Kernel.#open...

絞り込み条件を変える

IO#reopen(io) -> self (130.0)

自身を指定された io に繋ぎ換えます。

... io に繋ぎ換えます。

クラスも io に等しくなることに注意してください。
IO
#pos, IO#lineno などは指定された io と等しくなります。

@
param io 自身を繋ぎ換えたい IO オブジェクトを指定します。

@
raise IOError 指定された io が c...

IO#clone -> IO (26.0)

レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。

...シーバと同じ IO を参照する新しい IO オブジェクトを返します。
参照しているファイル記述子は dup(2) されます。

clone の際に self は一旦 IO#flush されます。
フリーズした IO の clone は同様にフリーズされた IO を返しますが、...
...しいフリーズされていない IO を返します。

@
raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
clone_io = nil
IO
.write("testfile", "test")
File.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}...

IO#dup -> IO (26.0)

レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。

...シーバと同じ IO を参照する新しい IO オブジェクトを返します。
参照しているファイル記述子は dup(2) されます。

clone の際に self は一旦 IO#flush されます。
フリーズした IO の clone は同様にフリーズされた IO を返しますが、...
...しいフリーズされていない IO を返します。

@
raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
clone_io = nil
IO
.write("testfile", "test")
File.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}...