6件ヒット
[1-6件を表示]
(0.103秒)
別のキーワード
ライブラリ
- ビルトイン (6)
キーワード
-
class
_ variable _ defined? (1) -
class
_ variable _ get (1) -
class
_ variable _ set (1) -
class
_ variables (1) -
remove
_ class _ variable (1) -
remove
_ const (1)
検索結果
先頭5件
-
Module
# class _ variable _ defined?(name) -> bool (18382.0) -
name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。
name で与えられた名前のクラス変数がモジュールに存在する場合 true を
返します。
@param name Symbol か String を指定します。
//emlist[例][ruby]{
class Fred
@@foo = 99
end
Fred.class_variable_defined?(:@@foo) #=> true
Fred.class_variable_defined?(:@@bar) #=> false
Fred.class_variable_defined?('@@foo') #=> true
Fred.class_variable... -
Module
# remove _ class _ variable(name) -> object (18364.0) -
引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。
...ールやクラスに定義されていない場合に発生します。
//emlist[例][ruby]{
class Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}
@see Module#remove_const, Object#remove_instance_variable... -
Module
# class _ variable _ get(name) -> object (18328.0) -
クラス/モジュールに定義されているクラス変数 name の値を返します。
クラス/モジュールに定義されているクラス変数 name の値を返します。
@param name String または Symbol を指定します。
@raise NameError クラス変数 name が定義されていない場合、発生します。
//emlist[例][ruby]{
class Fred
@@foo = 99
end
def Fred.foo
class_variable_get(:@@foo)
end
p Fred.foo #=> 99
//} -
Module
# class _ variable _ set(name , val) -> object (18328.0) -
クラス/モジュールにクラス変数 name を定義して、その値として val をセットします。val を返します。
クラス/モジュールにクラス変数 name を定義して、その値として
val をセットします。val を返します。
@param name String または Symbol を指定します。
//emlist[例][ruby]{
class Fred
@@foo = 99
def foo
@@foo
end
end
def Fred.foo(val)
class_variable_set(:@@foo, val)
end
p Fred.foo(101) # => 101
p Fred.new.foo # => 101
//} -
Module
# class _ variables(inherit = true) -> [Symbol] (18307.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...d
class 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... -
Module
# remove _ const(name) -> object (43.0) -
name で指定した定数を取り除き、その定数に設定されていた値を 返します。
...指定した(まだロードしてない)定数を含めて削除する事ができます。
取り除かれた定数は参照できなくなりますが、消える訳ではないので注意して
使用してください。
@see Module#remove_class_variable, Object#remove_instance_variable...