るりまサーチ

最速Rubyリファレンスマニュアル検索!
586件ヒット [101-200件を表示] (0.127秒)

別のキーワード

  1. kernel spawn
  2. kernel exec
  3. kernel system
  4. kernel open
  5. kernel caller

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

Module#module_eval(expr, fname = "(eval)", lineno = 1) -> object (3051.0)

モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。

...
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ただし、ローカル変数は module_eval/class_eval の外側のスコープと共有します。

定数とクラス変数のスコープは、文字列が与えられた場合とブロック...
...きます。

//emlist[例][ruby]{
class
C
end
a = 1
C.class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end
}

p C.new.m #=> [:m, 1]
//}

//emlist[定数のスコープが異なる例][ruby]{
class
C
end

# ブロックが渡された...
...ルに定数 X を定義する。
C.class_eval { X = 1 }

# 文字列が渡された場合は、モジュール定義式内と同じスコープになる。つまり、この場合は
# class C
# X = 2
# end
# と書いたのと同じ意味になる。
C.class_eval 'X = 2'

p X #=> 1
p C::X #=>...

ARGF.class#gets(limit) -> String | nil (3019.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(limit, chomp: false) -> String | nil (3019.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 = $/) -> String | nil (3019.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 (3019.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) -> String | nil (3019.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 (3019.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#readline(limit) -> String (3013.0)

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

...りなしとみなします。空文字列 "" を指定すると連続する改行を行
の区切りとみなします(パラグラフモード)。

@param limit 最大の読み込みバイト数

@raise EOFError EOFに達したら発生する

@see Kernel.#readline, ARGF.class#gets...

ARGF.class#readline(rs = $/) -> String (3013.0)

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

...りなしとみなします。空文字列 "" を指定すると連続する改行を行
の区切りとみなします(パラグラフモード)。

@param limit 最大の読み込みバイト数

@raise EOFError EOFに達したら発生する

@see Kernel.#readline, ARGF.class#gets...

ARGF.class#readline(rs, limit) -> String (3013.0)

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

...りなしとみなします。空文字列 "" を指定すると連続する改行を行
の区切りとみなします(パラグラフモード)。

@param limit 最大の読み込みバイト数

@raise EOFError EOFに達したら発生する

@see Kernel.#readline, ARGF.class#gets...

絞り込み条件を変える

ARGF.class#print(*arg) -> nil (3007.0)

引数を順に処理対象のファイルに出力します。

...引数を順に処理対象のファイルに出力します。

c:ARGF#inplace時にのみ使用できます。
また $stdout への代入の影響を受けません。
それ以外は Kernel.#print と同じです。

@param arg 出力するオブジェクトを任意個指定します。...

ARGF.class#printf(format, *arg) -> nil (3007.0)

C 言語の printf と同じように、format に従い引数を 文字列に変換して処理対象のファイルに出力します。

...c:ARGF#inplace時にのみ使用できます。
また $stdout への代入の影響を受けません。
それ以外は出力先を指定しない形式の Kernel.#printf と同じです。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。...
<< < 1 2 3 4 ... > >>