120件ヒット
[101-120件を表示]
(0.121秒)
別のキーワード
ライブラリ
- ビルトイン (120)
キーワード
- autoload (12)
-
const
_ defined? (12) -
const
_ get (12) -
const
_ missing (12) -
const
_ source _ location (12) - constants (12)
-
private
_ constant (12) -
public
_ constant (12) -
remove
_ const (12) -
singleton
_ class? (12)
検索結果
-
Module
# public _ constant(*name) -> self (12214.0) -
name で指定した定数の可視性を public に変更します。
...String か Symbol を指定します。
@raise NameError 存在しない定数を指定した場合に発生します。
@return self を返します。
//emlist[例][ruby]{
module SampleModule
class SampleInnerClass
end
# => 非公開クラスであることを明示するために privat......ate_constant :SampleInnerClass
end
begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::SampleInnerClass referenced>
end
module SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_consta......nt :SampleInnerClass
end
SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}
@see Module#private_constant, Object#untrusted?... -
Module
# autoload(const _ name , feature) -> nil (6268.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoload......ram const_name String または Symbol で指定します。
なお、const_name には、"::" 演算子を含めることはできません。
つまり、self の直下に定義された定数しか指定できません。
@param feature Kernel.#require と同様な方法で autoloa......ist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
autoload :Bar, '/tmp/foo'
end
p Foo::Bar #=> Foo::Bar
//}
以下のようにモジュールを明示的にレシーバとして呼び出すこともできます。
//emlist[...