ライブラリ
- ビルトイン (9)
検索結果
先頭5件
-
ARGF
. class # readchar -> String (27676.0) -
ARGFから 1 文字読み込んで、その文字に対応する String を返します。EOF に 到達した時には EOFErrorを発生します。
...rorを発生します。
@raise EOFError EOFに達した時発生する
$ echo "foo" > file
$ ruby argf.rb file
ARGF.readchar # => "f"
ARGF.readchar # => "o"
ARGF.readchar # => "o"
ARGF.readchar # => "\n"
ARGF.readchar # => end of file reached (EOFError)
@see ARGF.class#getc... -
ARGF
. class # filename -> String (18667.0) -
現在開いている処理対象のファイル名を返します。
現在開いている処理対象のファイル名を返します。
標準入力に対しては - を返します。
組み込み変数 $FILENAME と同じです。
$ echo "foo" > foo
$ echo "bar" > bar
$ echo "glark" > glark
$ ruby argf.rb foo bar glark
ARGF.filename # => "foo"
ARGF.read(5) # => "foo\nb"
ARGF.filename # => "bar"
ARGF.skip
ARGF.filename # => "glark" -
ARGF
. class # path -> String (18667.0) -
現在開いている処理対象のファイル名を返します。
現在開いている処理対象のファイル名を返します。
標準入力に対しては - を返します。
組み込み変数 $FILENAME と同じです。
$ echo "foo" > foo
$ echo "bar" > bar
$ echo "glark" > glark
$ ruby argf.rb foo bar glark
ARGF.filename # => "foo"
ARGF.read(5) # => "foo\nb"
ARGF.filename # => "bar"
ARGF.skip
ARGF.filename # => "glark" -
ARGF
. class # inplace _ mode -> String | nil (18646.0) -
c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡 張子を返します。拡張子が設定されていない場合は空文字列を返します。イン プレースモードでない場合は nil を返します。
...は空文字列を返します。イン
プレースモードでない場合は nil を返します。
Ruby 起動時の -i オプション や ARGF.class#inplace_mode= で設定します。
例:
# $ echo "test" > test.txt
# $ ruby -i.bak test.rb test.txt
# $ cat test.txt # => "TEST"
# $ c......ine {|e|print e.upcase} # => "TEST"
例:
# $ echo "test" > test.txt
# $ ruby test.rb test.txt
# $ cat test.txt # => "test"
# test.rb
ARGF.inplace_mode # => nil
ARGF.each_line {|e|print e.upcase} # => "TEST"
@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode=... -
ARGF
. class # read(length = nil , str = nil) -> String | nil (18646.0) -
ARGVに指定されたファイルを先頭のファイルからlengthバイト読み込み、 その文字列をstrに出力します。読み込んだ文字列を返します。
ARGVに指定されたファイルを先頭のファイルからlengthバイト読み込み、
その文字列をstrに出力します。読み込んだ文字列を返します。
@param length 読み込むバイト数を指定します。nilの場合はARGVのすべてのファ
イルを読み込みます。
@param str 出力先の文字列。内容は上書きされます。
$ echo "small" > small.txt
$ echo "large" > large.txt
$ ruby glark.rb small.txt large.txt
ARGF.read # => "sm... -
ARGF
. class # gets(limit , chomp: false) -> String | nil (9688.0) -
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。
...est.txt
# test.rb
ARGF.gets("e") # => "line"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"
@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc... -
ARGF
. class # gets(rs = $ / , chomp: false) -> String | nil (9688.0) -
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。
...est.txt
# test.rb
ARGF.gets("e") # => "line"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"
@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc... -
ARGF
. class # gets(rs , limit , chomp: false) -> String | nil (9688.0) -
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。
...est.txt
# test.rb
ARGF.gets("e") # => "line"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"
@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc... -
ARGF
. class # getc -> String | nil (9364.0) -
self から 1 文字読み込んで返します。EOF に到達した時には nil を返します。
...foo" > file1
$ echo "bar" > file2
$ ruby argf.rb file1 file2
ARGF.getc # => "f"
ARGF.getc # => "o"
ARGF.getc # => "o"
ARGF.getc # => "\n"
ARGF.getc # => "b"
ARGF.getc # => "a"
ARGF.getc # => "r"
ARGF.getc # => "\n"
ARGF.getc # => nil
@see ARGF.class#getbyte, ARGF.class#gets...