るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. singleton clone
  2. singleton dup
  3. singleton instance
  4. object define_singleton_method
  5. _builtin define_singleton_method

ライブラリ

クラス

キーワード

検索結果

Object#singleton_class -> Class (54361.0)

レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。

レシーバの特異クラスを返します。
まだ特異クラスがなければ、新しく作成します。

レシーバが nil か true か false なら、それぞれ NilClass, TrueClass,
FalseClass を返します。

@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。

//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
n...

Module#singleton_class? -> bool (18361.0)

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

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

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

Module#private_class_method(*name) -> self (40.0)

name で指定したクラスメソッド (クラスの特異メソッド) の 可視性を private に変更します。

name で指定したクラスメソッド (クラスの特異メソッド) の
可視性を private に変更します。

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

//emlist[例][ruby]{
module Foo
def self.foo; end
end

Foo.singleton_class.private_method_defined?(:foo) # => false
Foo.private_class_method(:foo) # => Foo
Foo.singleton_class.private_method_define...