797件ヒット
[1-100件を表示]
(0.064秒)
クラス
-
ARGF
. class (22) - Dir (149)
- File (110)
-
File
:: Stat (11) - IO (437)
- Object (26)
-
Thread
:: Queue (9)
モジュール
- Enumerable (33)
キーワード
- <=> (11)
- advise (11)
- atime (11)
- autoclose= (11)
- autoclose? (11)
- binmode (11)
- children (6)
- chown (11)
- chunk (11)
- clone (11)
- close (20)
-
close
_ on _ exec= (11) -
close
_ on _ exec? (11) - ctime (11)
- dup (11)
- each (22)
-
each
_ byte (22) -
each
_ child (12) -
each
_ codepoint (22) - eof (11)
- eof? (11)
-
external
_ encoding (11) - fcntl (11)
- fdatasync (11)
- fileno (10)
- flock (11)
- flush (11)
- inspect (11)
-
internal
_ encoding (11) - lstat (11)
- mtime (11)
- path (22)
- pos (22)
- pos= (22)
- pread (7)
- pwrite (7)
- read (22)
- readbyte (11)
- readlines (33)
- reopen (33)
- rewind (11)
- seek (11)
-
set
_ encoding (33) -
set
_ encoding _ by _ bom (5) - size (11)
-
slice
_ before (22) - stat (11)
- sync (11)
- sysread (11)
- sysseek (11)
- syswrite (11)
- tell (22)
- then (12)
-
to
_ path (22) - truncate (11)
- write (11)
-
yield
_ self (14)
検索結果
先頭5件
-
IO
# reopen(path) -> self (6109.0) -
path で指定されたファイルにストリームを繋ぎ換えます。
...int("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 (6109.0) -
path で指定されたファイルにストリームを繋ぎ換えます。
...int("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 (6104.0) -
自身を指定された io に繋ぎ換えます。
自身を指定された io に繋ぎ換えます。
クラスも io に等しくなることに注意してください。
IO#pos, IO#lineno などは指定された io と等しくなります。
@param io 自身を繋ぎ換えたい IO オブジェクトを指定します。
@raise IOError 指定された io が close されている場合に発生します。 -
IO
# readlines(limit , chomp: false) -> [String] (33.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
..."testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # =>......rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}... -
IO
# readlines(rs = $ / , chomp: false) -> [String] (33.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
..."testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # =>......rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}... -
IO
# readlines(rs , limit , chomp: false) -> [String] (33.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
..."testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # =>......rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}... -
File
# flock(operation) -> 0 | false (27.0) -
ファイルをロックします。
...けません。
File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
f.flock(File::LOCK_EX)
value = f.read.to_i + 1
f.rewind
f.write("#{value}\n")
f.flush
f.truncate(f.pos)
}
# 読み込みロック(read lock)を使用してカウンタを読み込み。
File.open("counter", "r") {|f......|
f.flock(File::LOCK_SH)
p f.read
}
//}
//emlist[例2:][ruby]{
f = File.open("/tmp/foo", "w")
f.flock(File::LOCK_EX)
puts "locked by process1"
fork {
f = File.open("/tmp/foo", "r")
f.flock(File::LOCK_SH)
puts "locked by process2"
sleep 5
puts "unlocked by process2"
}
sleep 5
f.flo... -
Dir
# read -> String | nil (21.0) -
ディレクトリストリームから次の要素を読み出して返します。最後の要素 まで読み出していれば nil を返します。
...します。
//emlist[例][ruby]{
require 'tmpdir'
Dir.mktmpdir do |tmpdir|
File.open("#{tmpdir}/test1.txt", "w") { |f| f.puts("test1") }
File.open("#{tmpdir}/test2.txt", "w") { |f| f.puts("test2") }
Dir.open(tmpdir) do |d|
p d.read # => "."
p d.read # => ".."
p d.read # =>... -
File
# path -> String (21.0) -
オープン時に使用したパスを文字列で返します。
...作成されていたりする場合です。
//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}......されている場合に発生します。
//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } # IOError: File is un... -
File
# to _ path -> String (21.0) -
オープン時に使用したパスを文字列で返します。
...作成されていたりする場合です。
//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}......されている場合に発生します。
//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } # IOError: File is un...