るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. document implicit_end

ライブラリ

クラス

検索結果

Module#public_constant(*name) -> self (18138.0)

name で指定した定数の可視性を public に変更します。

...ます。

@return self を返します。

//emlist[例][ruby]{
module SampleModule
class SampleInnerClass
end


# => 非公開クラスであることを明示するために private にする
private_constant :SampleInnerClass
end


begin
SampleModule::SampleInnerClass
rescue => e
e # =...
...#<NameError: private constant SampleModule::SampleInnerClass referenced>
end


module SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant
:SampleInnerClass
end


SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}...

Module#private_constant(*name) -> self (31.0)

name で指定した定数の可視性を private に変更します。

...ます。

@return self を返します。

@see Module#public_constant, Object#untrusted?

//emlist[例][ruby]{
module Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end

private_constant :QUX
private_constant :Quux
end


Foo::BAR # => "bar"
Foo::Baz # => Foo::Baz
Foo::QUX # =...
...に発生します。

@return self を返します。

@see Module#public_constant

//emlist[例][ruby]{
module Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end

private_constant :QUX
private_constant :Quux
end


Foo::BAR # => "bar"
Foo::Baz # => Foo::Baz
Foo::QUX # => NameE...