るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合は...
...ng など
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 (18170.0)

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

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

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合は...
...ng など
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 (18170.0)

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

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

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合は...
...ng など
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...

CSV.read(path, options = Hash.new) -> [Array] | CSV::Table (18126.0)

CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。

...なければなりません。

//emlist[例][ruby]{
require "csv"
require "pp"

File
.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV

pp CSV.read("test.csv")

# => [["id", "first name", "last name", "age"],
# ["1", "taro",...
...,
# ["4", "yumi", "adachi", "21"]]
//}

//emlist[例][ruby]{
require "csv"

File
.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV

table = CSV.read("test.csv", headers: true)
p table.class # => CSV::Table
p table[0] # =>...

File.readlink(path) -> String (15113.0)

シンボリックリンクのリンク先のパスを文字列で返します。

...XX 指定された path がシンボリックリンクでない場合や、リンクの読み取りに失敗した場合に発生します。

//emlist[例:][ruby]{
IO.write("testfile", "test")
File
.symlink("testfile", "testlink") # => 0
File
.readlink("testlink") # => "testfile"
//}...

絞り込み条件を変える

File.world_readable?(path) -> Integer | nil (15107.0)

path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。

...場合は nil を返します。

整数の意味はプラットフォームに依存します。

@param path パスを表す文字列か IO オブジェクトを指定します。

//emlist[例][ruby]{
m = File.world_readable?("/etc/passwd")
"%o" % m # => "644"
//}...

File.readable?(path) -> bool (15101.0)

FileTest.#readable? と同じです。

...
File
Test.#readable? と同じです。

@param path パスを表す文字列か IO オブジェクトを指定します。...

File.readable_real?(path) -> bool (15101.0)

FileTest.#readable_real? と同じです。

...
File
Test.#readable_real? と同じです。

@param path パスを表す文字列か IO オブジェクトを指定します。...

File.new(path, mode = "r", perm = 0666) -> File (9192.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...File オブジェクトを生成して
返します。

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...mlist[例: File.new による読み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close...
...//}

//emlist[例: File.open による書き込みモードでのファイルオープン][ruby]{
File
.open("testfile", "w", 0755) { |f| f.print "test" }
File
.read("testfile") # => "test"
//}...
<< 1 2 3 ... > >>