るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.098秒)
トップページ > クエリ:ruby[x] > クエリ:String[x] > クエリ:string[x] > 種類:インスタンスメソッド[x] > クエリ:@[x] > クラス:Module[x] > クエリ:public_constant[x]

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub!

ライブラリ

検索結果

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

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

...視性を public に変更します。

@
param name 0 個以上の String か Symbol を指定します。

@
raise NameError 存在しない定数を指定した場合に発生します。

@
return self を返します。

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

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

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

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

@
see Module#private_constant, Object#untrusted?...
...leInnerClass # => SampleModule::SampleInnerClass
//}

@
see Module#private_constant...

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

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

...変更します。

@
param name 0 個以上の String か Symbol を指定します。

@
raise NameError 存在しない定数を指定した場合に発生します。

@
return self を返します。

@
see Module#public_constant, Object#untrusted?

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
c...
...private に変更します。

@
param name 0 個以上の String か Symbol を指定します。

@
raise NameError 存在しない定数を指定した場合に発生します。

@
return self を返します。

@
see Module#public_constant

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
class Ba...