class File

Fileクラス ↑

ファイル制御するクラス

Public Class Methods

new(path, mode = "r") click to toggle source
コンストラクタ
Fileオブジェクトを生成する。

Args ↑

path ファイル名 ↑

mode ファイルオープンモード ↑

"r" 読み込みモード
"w" 書き込みモード
"a" 追加モード
"r+" 読み書きモード
"w+" 空にして読み書きモード
"a+" 追加モード

Return ↑

生成されたFileオブジェクト

Exception ↑

ArgumentError パラメータエラー ↑

IOError IOエラー ↑

# File file.rb, line 22
def initialize(path, mode = "r")
end

Public Instance Methods

close() click to toggle source
ファイルクローズ
ファイルをクローズする。

Args ↑

Return ↑

nil

Exception ↑

IOError IOエラー ↑

# File file.rb, line 106
def close
  nil
end
flush() click to toggle source
ファイルのフラッシュ
ファイルバッファをフラッシュする。

Args ↑

Return ↑

self

Exception ↑

IOError IOエラー ↑

# File file.rb, line 133
def flush
  self # dummy
end
getc() click to toggle source
1文字読み込み
ファイルより1文字の値を読み込む。

Args ↑

Return ↑

    ファイル入力データ(文字列)
EOFに到達した場合はnilを返す。

Exception ↑

IOError IOエラー ↑

# File file.rb, line 57
def getc
  " " # dummy
end
gets(rs="", limit=127) click to toggle source
行読み込み
ファイルより1行のデータを読み込む。

Args ↑

rs 行の区切り文字(省略時は“\n”) ↑

limit 読み込み最大文字数(省略時は127) ↑

Return ↑

ファイル入力データ(文字列)
EOFに到達した場合はnilを返す。

Exception ↑

IOError IOエラー ↑

# File file.rb, line 83
def gets(rs="", limit=127)
  " " # dummy
end
putc(v) click to toggle source
1文字書き込み
ファイルへ1文字の値を書き込む。

Args ↑

v 出力文字(文字列または文字コード) ↑

Return ↑

出力した文字

Exception ↑

IOError IOエラー ↑

# File file.rb, line 69
def putc(v)
  v # dummy
end
puts(*obj) click to toggle source
行書き込み
引数で渡されたオブジェクトを出力し、それぞれの後に改行を出力する。

Args ↑

obj 出力するオブジェクト ↑

Return ↑

nil

Exception ↑

IOError IOエラー ↑

# File file.rb, line 95
def puts(*obj)
  nil # dummy
end
read(len) click to toggle source
ファイル読み込み
ファイルより指定バイト数の値を読み込む。

Args ↑

len 読み込むバイト数 ↑

Return ↑

ファイル入力データ(文字列)

Exception ↑

IOError IOエラー ↑

# File file.rb, line 33
def read(len)
  " " * len # dummy
end
seek(offset, whence = File::SEEK_SET) click to toggle source
ファイルシーク
ファイルポインタを指定の位置に移動する。

Args ↑

offset ファイルポインタを移動させるオフセット ↑

whence ファイルポインタ起点 ↑

_File::SEEK_SET_ ファイル先頭から(デフォルト) ↑
_File::SEEK_CUR_ 現在のファイルポインタから ↑
_File::SEEK_END_ ファイル末尾から ↑

Return ↑

0

Exception ↑

IOError IOエラー ↑

# File file.rb, line 122
def seek(offset, whence = File::SEEK_SET)
  0 # dummy
end
size() click to toggle source
ファイルサイズ取得
ファイルサイズを取得する。

Args ↑

Return ↑

ファイルサイズ

Exception ↑

IOError IOエラー ↑

# File file.rb, line 144
def size
  1 # dummy
end
write(v) click to toggle source
ファイル書き込み
指定文字列をファイルへ書き込む。

Args ↑

v 出力データ(文字列) ↑

Return ↑

出力したバイト数

Exception ↑

IOError IOエラー ↑

# File file.rb, line 45
def write(v)
  v.length # dummy
end