るりまサーチ

最速Rubyリファレンスマニュアル検索!
2696件ヒット [2401-2500件を表示] (0.071秒)
トップページ > クエリ:Kernel.#p[x] > クエリ:cpp_command[x] > クエリ:eval[x] > クエリ:spawn[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. mkmf try_cpp
  2. mkmf egrep_cpp
  3. kernel try_cpp
  4. kernel egrep_cpp
  5. mkmf cpp_command

クラス

モジュール

キーワード

検索結果

<< < ... 23 24 25 26 27 > >>

Module#constants(inherit = true) -> [Symbol] (38.0)

そのモジュール(またはクラス)で定義されている定数名の配列を返します。

...ません。

@param inherit true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables...
...nd
class Bar
BAR = 1

# Bar は BAR を含む
p
constants # => [:BAR]
# 出力に FOO は含まれない
p
Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p
constants # => []

#...
...ネストしたクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constants には含まれる
# (クラス Baz も Bar の定数なので同様)
p
Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}...

Object#send(name, *args) -> object (38.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...ドを呼び出せます。
d:spec/def#limit も参照してください。

p
ublic メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッド...
...に渡す引数です。

//emlist[][ruby]{
p
-365.send(:abs) #=> 365
p
"ruby".send(:sub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p
Foo.new.send(methods[1]) # => "foo"
p
Foo.new.send(methods[2]) # => "bar"
p
Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...

Object#send(name, *args) { .... } -> object (38.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...ドを呼び出せます。
d:spec/def#limit も参照してください。

p
ublic メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッド...
...に渡す引数です。

//emlist[][ruby]{
p
-365.send(:abs) #=> 365
p
"ruby".send(:sub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p
Foo.new.send(methods[1]) # => "foo"
p
Foo.new.send(methods[2]) # => "bar"
p
Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...

Module#ancestors -> [Class, Module] (32.0)

クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。

...先順位順に配列に格納して返します。

//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p
ancestors
p
included_modules
p
superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}

@see Module#included_modules...

Module#const_defined?(name, inherit = true) -> bool (32.0)

モジュールに name で指定される名前の定数が定義されている時真 を返します。

...とができます。

@param name String, Symbol で指定される定数名。

@param inherit false を指定するとスーパークラスや include したモジュールで
定義された定数は対象にはなりません。

//emlist[例][ruby]{
module Kernel
FOO = 1
end

# Object...
...include したモジュールの定数に対しても
# true を返す
p
Object.const_defined?(:FOO) # => true

module Bar
BAR = 1
end
class Object
include Bar
end
# ユーザ定義のモジュールに対しても同様
p
Object.const_defined?(:BAR) # => true

class Baz
include Bar
end
#...
...Object 以外でも同様になった
# 第二引数のデフォルト値が true であるため
p
Baz.const_defined?(:BAR) # => true

# 第二引数を false にした場合
p
Baz.const_defined?(:BAR, false) # => false
//}...

絞り込み条件を変える

Thread#exit -> self (32.0)

スレッドの実行を終了させます。終了時に ensure 節が実行されます。

...スを Kernel.#exit(0)
により終了します。

Kernel
.#exit と違い例外 SystemExit を発生しません。

th1 = Thread.new do
begin
sleep 10
ensure
p
"this will be displayed"
end
end

sleep 0.1
th1.kill

#=> "this will be displayed"

@see Kernel.#exit,...

Thread#kill -> self (32.0)

スレッドの実行を終了させます。終了時に ensure 節が実行されます。

...スを Kernel.#exit(0)
により終了します。

Kernel
.#exit と違い例外 SystemExit を発生しません。

th1 = Thread.new do
begin
sleep 10
ensure
p
"this will be displayed"
end
end

sleep 0.1
th1.kill

#=> "this will be displayed"

@see Kernel.#exit,...

Thread#terminate -> self (32.0)

スレッドの実行を終了させます。終了時に ensure 節が実行されます。

...スを Kernel.#exit(0)
により終了します。

Kernel
.#exit と違い例外 SystemExit を発生しません。

th1 = Thread.new do
begin
sleep 10
ensure
p
"this will be displayed"
end
end

sleep 0.1
th1.kill

#=> "this will be displayed"

@see Kernel.#exit,...

ARGF (26.0)

スクリプトに指定した引数 (Object::ARGV を参照) をファイル名とみなして、 それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。 ARGV が空なら標準入力を対象とします。 ARGV を変更すればこのオブジェクトの動作に影響します。

...に影響します。

//emlist[][ruby]{
while line = ARGF.gets
# do something
end
//}

は、

//emlist[][ruby]{
while argv = ARGV.shift
File.open(argv) {|file|
while line = file.gets
# do something
end
}
end
//}

のように動作します。

ARGF を処理するごとに ARG...
...ruby]{
ARGV.replace %w(/tmp/foo /tmp/bar)
ARGF.each {|line|
# 処理中の ARGV の内容を表示
p
[ARGF.filename, ARGV]
ARGF.skip
}
# => ["/tmp/foo", ["/tmp/bar"]]
# ["/tmp/bar", []]
# 最後まで読んだ後 (ARGV が空) の動作
p
ARGF.gets # => nil
p
ARGF.filenam...
...e # => "-"
//}

Kernel
.#gets など一部の組み込み関数は
ARGF.gets などこのオブジェクトをレシーバとしたメソッドの省略形です。

また、ARGF は ARGF.class クラスのインスタンスです。
各メソッドの詳細は ARGF.class を参照してくださ...
<< < ... 23 24 25 26 27 > >>