るりまサーチ

最速Rubyリファレンスマニュアル検索!
910件ヒット [1-100件を表示] (0.050秒)
トップページ > クエリ:File[x] > クラス:IO[x]

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file open
  4. base file
  5. file size

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

IO#fileno -> Integer (6101.0)

ファイル記述子を表す整数を返します。

...ファイル記述子を表す整数を返します。

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


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}...
...ファイル記述子を表す整数を返します。

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


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}

@see Dir#fileno...

IO#to_i -> Integer (3001.0)

ファイル記述子を表す整数を返します。

...ファイル記述子を表す整数を返します。

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


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}...
...ファイル記述子を表す整数を返します。

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


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}

@see Dir#fileno...

IO#stat -> File::Stat (142.0)

ファイルのステータスを含む File::Stat オブジェクトを生成して 返します。

...タスを含む File::Stat オブジェクトを生成して
返します。

@raise Errno::EXXX ステータスの読み込みに失敗した場合に発生します。

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

//emlist[例][ruby]{
IO
.write("testfile", "This is line...
...one\nThis is line two\n")
File
.open("testfile") do |f|
s = f.stat
"%o" % s.mode # => "100644"
s.blksize # => 4096
s.atime # => 2018-03-01 23:19:59 +0900
end
//}

@see File#lstat, File.stat, File.lstat...

IO.console -> File | nil (124.0)

端末を File オブジェクトで返します。

...端末を File オブジェクトで返します。

require "io/console"
IO
.console # => #<File:/dev/tty>

プロセスが端末から切り離された状態で実行すると nil を返します。

戻り値はプラットフォームや環境に依存します。...

IO#readlines(limit, chomp: false) -> [String] (31.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...す。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File
.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File
.open("testfile") { |f| p f.r...
...n", "e2,", "\n", "lin", "e3,", "\n"]
File
.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}

//emlist[例: 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"]
//}

@see $/, IO#gets...

絞り込み条件を変える

IO#readlines(rs = $/, chomp: false) -> [String] (31.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...す。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File
.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File
.open("testfile") { |f| p f.r...
...n", "e2,", "\n", "lin", "e3,", "\n"]
File
.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}

//emlist[例: 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"]
//}

@see $/, IO#gets...

IO#readlines(rs, limit, chomp: false) -> [String] (31.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...す。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File
.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File
.open("testfile") { |f| p f.r...
...n", "e2,", "\n", "lin", "e3,", "\n"]
File
.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}

//emlist[例: 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"]
//}

@see $/, IO#gets...

IO.read(path, **opt) -> String | nil (31.0)

path で指定されたファイルを offset 位置から length バイト分読み込んで返します。

...場合は nil を返します。ただし、length に nil か 0 が指定されている場合は、空文字列 "" を返します。例えば、IO.read(空ファイル) は "" を返します。

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合...
...e

IO
.open のモードを指定します。
"r" で始まる文字列である必要があります。

: :open_args

IO
.open に渡される引数を配列で指定します。

これらの他、 :external_encoding など
IO
.open のオプション引数が指定できます。

@see IO...
....binread

例:

IO
.read(empty_file) #=> ""
IO
.read(empty_file, 1) #=> nil
IO
.read(one_byte_file, 0, 10) #=> ""
IO
.read(one_byte_file, nil, 10) #=> ""
IO
.read(one_byte_file, 1, 10) #=> nil...

IO.read(path, length = nil, **opt) -> String | nil (31.0)

path で指定されたファイルを offset 位置から length バイト分読み込んで返します。

...場合は nil を返します。ただし、length に nil か 0 が指定されている場合は、空文字列 "" を返します。例えば、IO.read(空ファイル) は "" を返します。

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合...
...e

IO
.open のモードを指定します。
"r" で始まる文字列である必要があります。

: :open_args

IO
.open に渡される引数を配列で指定します。

これらの他、 :external_encoding など
IO
.open のオプション引数が指定できます。

@see IO...
....binread

例:

IO
.read(empty_file) #=> ""
IO
.read(empty_file, 1) #=> nil
IO
.read(one_byte_file, 0, 10) #=> ""
IO
.read(one_byte_file, nil, 10) #=> ""
IO
.read(one_byte_file, 1, 10) #=> nil...

IO.read(path, length = nil, offset = 0, **opt) -> String | nil (31.0)

path で指定されたファイルを offset 位置から length バイト分読み込んで返します。

...場合は nil を返します。ただし、length に nil か 0 が指定されている場合は、空文字列 "" を返します。例えば、IO.read(空ファイル) は "" を返します。

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合...
...e

IO
.open のモードを指定します。
"r" で始まる文字列である必要があります。

: :open_args

IO
.open に渡される引数を配列で指定します。

これらの他、 :external_encoding など
IO
.open のオプション引数が指定できます。

@see IO...
....binread

例:

IO
.read(empty_file) #=> ""
IO
.read(empty_file, 1) #=> nil
IO
.read(one_byte_file, 0, 10) #=> ""
IO
.read(one_byte_file, nil, 10) #=> ""
IO
.read(one_byte_file, 1, 10) #=> nil...

絞り込み条件を変える

<< 1 2 3 ... > >>