るりまサーチ

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

別のキーワード

  1. socket local_creds
  2. socket local_peercred
  3. socket af_local
  4. socket local_connwait
  5. socket pf_local

ライブラリ

クラス

キーワード

検索結果

Binding#local_variables -> [Symbol] (24230.0)

ローカル変数の一覧を Symbol の配列で返します。

...カル変数の一覧を Symbol の配列で返します。

//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}

このメソッドは以下のコードと同様の動作をします。

//emlist[][ruby]{
binding.eval("local_variables")
//}...

NameError#local_variables -> [Symbol] (24220.0)

self が発生した時に定義されていたローカル変数名の一覧を返します。

...発生した時に定義されていたローカル変数名の一覧を返します。

内部での使用に限ります。

例:

def foo
begin
b = "bar"
c
= 123
d
rescue NameError => err
p err.local_variables #=> [:b, :c, :err]
end
end

a = "buz"
foo...

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

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

...ルードしているモジュールの定数も含みます。
Object のサブクラスの場合、Objectやそのスーパークラスで定義されている
定数は含まれません。 Object.constants とすると Object クラスで定義された
定数の配列が得られます。

...
...include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables

//emlist[Module.constan...
...ts と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.constants

c
lass Foo
FOO = 1
end
c
lass Bar
BAR = 1

# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は...

Module#class_variables(inherit = true) -> [Symbol] (6107.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...y]{
c
lass One
@@var1 = 1
end
c
lass Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_...
...variables, Module#constants...

Object#instance_variables -> [Symbol] (6107.0)

オブジェクトのインスタンス変数名をシンボルの配列として返します。

...列として返します。

//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables

#=> [:@foo, :@bar]
//}

@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables...

絞り込み条件を変える

TracePoint#binding -> Binding | nil (3041.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...

C
で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # =...
...> [:ret]
end
trace.enable
foo 1
//}...

TracePoint#binding -> Binding (3023.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}...