るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

検索結果

Module#deprecate_constant(*name) -> self (6233.0)

name で指定した定数を deprecate に設定します。 deprecate に設定した定数を参照すると警告メッセージが表示されます。

...セージが表示されます。

Ruby
2.7.2 から Warning[:deprecated] のデフォルト値が false に変更になったため、
デフォルトでは警告が表示されません。

コマンドラインオプション(詳細はd:spec/rubycmd#cmd_option参照)で、
「-w」か「-W2」な...
...い定数を指定した場合に発生します。

@return self を返します。

//emlist[例][ruby]{
FOO = 123
Object.deprecate_constant(:FOO) # => Object

FOO
# warning: constant ::FOO is deprecated
# => 123

Object.deprecate_constant(:BAR)
# NameError: constant Object::BAR not defined
//}...

Module#private_constant(*name) -> self (6221.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 # => NameError: private constant Foo::QUX referenced
Foo::Quux # => NameError: private constant Foo::Quux referenced
//}...
...@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 # => NameError: private constant...
...Foo::QUX referenced
Foo::Quux # => NameError: private constant Foo::Quux referenced
//}...

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

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

...発生します。

@return self を返します。

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

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

begin
SampleModule::SampleInnerClass
rescue =>...
...ate constant SampleModule::SampleInnerClass referenced>
end

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

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

@see Module#pri...
...vate_constant, Object#untrusted?...
...vate_constant...

Module#singleton_class? -> bool (6130.0)

self が特異クラスの場合に true を返します。そうでなければ false を返し ます。

...
self
が特異クラスの場合に true を返します。そうでなければ false を返し
ます。

//emlist[例][ruby]{
class C
end
C.singleton_class? # => false
C.singleton_class.singleton_class? # => true
//}...

Module#const_added(name) -> () (6120.0)

定数 name が追加された時にインタプリタがこのメソッドを呼び出します。

...定数 name が追加された時にインタプリタがこのメソッドを呼び出します。

//emlist[][ruby]{
module
Chatty
def self.const_added(const_name)
super
puts "Added #{const_name.inspect}"
end
FOO = 1
end
# => Added :FOO
//}...

絞り込み条件を変える

Module#autoload(const_name, feature) -> nil (144.0)

定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

...定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoload...
...に定義されているときは何もしません。

@param const_name String または Symbol で指定します。
なお、const_name には、"::" 演算子を含めることはできません。
つまり、self の直下に定義された定数しか指定できません。

@...
...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[例][ruby...