るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

ARGF.class#gets(limit) -> String | nil (25.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets(2) # => "li"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby t...
...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(limit, chomp: false) -> String | nil (25.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets(2) # => "li"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby t...
...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 = $/) -> String | nil (25.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets(2) # => "li"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby t...
...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 (25.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets(2) # => "li"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby t...
...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) -> String | nil (25.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets(2) # => "li"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby t...
...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 (25.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets(2) # => "li"

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby t...
...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#inplace_mode=(ext) (25.0)

c:ARGF#inplace時にバックアップファイルに付加する拡張子を設定します。 ピリオドも含めて指定する必要があります。

...

Ruby
起動時の -i オプションで設定することも出来ます。

@param ext インプレースモード時にバックアップファイルに付加する拡張子を
文字列で指定します。
ピリオドも含める必要があります。

$ ruby argf...
...e.sub("foo","bar")
end


---- -i オプションを使う場合 ----
$ ruby -i.bak -p -e '$_.sub!("foo","bar")' file.txt

---- -i オプションを使う場合その2 ----
$ ruby -i.bak -n -e 'print $_.sub("foo","bar")' file.txt

@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode...

ARGF.class#inplace_mode -> String | nil (19.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"
# $ cat test.txt.bak # =>...
...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#binmode -> self (13.0)

self をバイナリモードにします。一度バイナリモードになった後は非バイナリ モードに戻る事はできません。

...test1.png + test2.png = 292B

# $ ruby test.rb test1.png test2.png

ARGF.binmode
ARGF.read.size # => 292

例:
# test1.png - 164B
# test2.png - 128B
# test1.png + test2.png = 292B

# $ ruby test.rb test1.png test2.png

ARGF.read.size # => 290

@see IO#binmode, ARGF.class#binmode?...

ARGF.class#argv -> Array (7.0)

Object::ARGV を返します。

...Object::ARGV を返します。

ARGF が ARGV をどう扱うかについては ARGF を参照してください。

例:

$ ruby argf.rb -v glark.txt

ARGF.argv #=> ["-v", "glark.txt"]...

絞り込み条件を変える

ARGF.class#close -> self (7.0)

現在開いている処理対象のファイルをクローズします。開くファイルが残って いる場合は次のファイルをオープンします。 ただし、標準入力はクローズされません。

..."bar" > bar

$ ruby argf.rb foo bar

ARGF.filename # => "foo"
ARGF.close
ARGF.filename # => "bar"
ARGF.close
ARGF.close # => closed stream (IOError)

@raise IOError 処理対象のファイルが既にクローズされていた場合に発生します。

@see ARGF.class#closed?...
...いる場合は次のファイルをオープンします。
ただし、標準入力はクローズされません。

$ echo "foo" > foo
$ echo "bar" > bar

$ ruby argf.rb foo bar

ARGF.filename # => "foo"
ARGF.close
ARGF.filename # => "bar"
ARGF.close

@see ARGF.class#closed?...

ARGF.class#closed? -> bool (7.0)

現在開いている処理対象のファイルがARGFがcloseされていればtrueを返します。

...いる処理対象のファイルがARGFがcloseされていればtrueを返します。

例:
# $ echo "foo" > foo
# $ echo "bar" > bar
# $ ruby argf.rb foo bar

ARGF.filename # => "foo"
ARGF.close
# 複数のファイルを開いているので1度のARGF.closeではまた全てのフ...
...ルを閉じていないのでfalseになる
ARGF.closed? # => false
ARGF.filename # => "bar"
ARGF.close
# 2つのファイルを開いていたので2度目のARGF.closeで全てのファイルを閉じたためtrueになる
ARGF.closed? # => true

@see IO#closed?, ARGF.class#close...
<< 1 2 3 > >>