るりまサーチ

最速Rubyリファレンスマニュアル検索!
429件ヒット [1-100件を表示] (0.024秒)
トップページ > クエリ:class[x] > クエリ:Singleton[x]

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. class new
  5. argf.class gets

検索結果

<< 1 2 3 ... > >>

Singleton (38058.0)

Singleton パターンを提供するモジュールです。

...Singleton パターンを提供するモジュールです。

Mix-in により singleton パターンを提供します。

Singleton
モジュールを include することにより、クラスは
高々ひとつのインスタンスしか持たないことが保証されます。

Singleton
を M...
...e 'singleton'

class
SomeSingletonClass
include Singleton
#....
end

a = SomeSingletonClass.instance
b = SomeSingletonClass.instance # a and b are same object
p [a,b] # => [#<SomeSingletonClass:0x0000562e6e18ddd0>, #<SomeSingletonClass:0x0000562e6e18ddd0>]
a = SomeSingletonClass.n...
...ew # => NoMethodError (private method `new' called for SomeSingletonClass:Class)...

Object#singleton_class -> Class (12357.0)

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

...れ NilClass, TrueClass,
FalseClass を返します。

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

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

@see Object#class...

Module#singleton_class? -> bool (12244.0)

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

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

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

VALUE rb_singleton_class(VALUE obj) (12200.0)

obj に特異クラスを導入し、その特異クラスを返します。 すでに特異クラスが導入されているときはそれをそのまま返します。

obj に特異クラスを導入し、その特異クラスを返します。
すでに特異クラスが導入されているときはそれをそのまま返します。

obj が特異メソッドを定義できない型のオブジェクトである
ときは例外 TypeError を発生します。

VALUE rb_singleton_class_clone(VALUE klass) (12200.0)

特異クラス klass を clone して返します。 klass が特異クラスでないときはただ klass を返します。

特異クラス klass を clone して返します。
klass が特異クラスでないときはただ klass を返します。

絞り込み条件を変える

VALUE rb_singleton_class_new(VALUE super) (12200.0)

super をスーパークラスとする特異クラスを生成し、返します。

super をスーパークラスとする特異クラスを生成し、返します。

void rb_singleton_class_attached(VALUE klass, VALUE obj) (12200.0)

特異クラス klass にその唯一のインスタンス obj を結びつけます。

特異クラス klass にその唯一のインスタンス obj を結びつけます。

Object#singleton_methods(inherited_too = true) -> [Symbol] (6245.0)

そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。

...加された特異メソッドや、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。

singleton
_methods(false) は、Object#methods(false) と同じです。

@param inherited_too 継承した特異メソッ...
...by]{
Parent = Class.new

class
<<Parent
private; def private_class_parent() end
protected; def protected_class_parent() end
public; def public_class_parent() end
end

Foo = Class.new(Parent)

class
<<Foo
private; def private_class_foo() end
protected; def protected_class_foo() end...
...public; def public_class_foo() end
end

module Bar
private; def private_bar() end
protected; def protected_bar() end
public; def public_bar() end
end

obj = Foo.new
class
<<obj
include Bar
private; def private_self() end
protected; def protected_self() end
public;...

BasicObject#singleton_method_undefined(name) -> object (6149.0)

特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。

...][ruby]{
class
Foo
def singleton_method_undefined(name)
puts "singleton method \"#{name}\" was undefined"
end
end

obj = Foo.new
def obj.foo
end
def obj.bar
end

class
<< obj
undef_method :foo
end
obj.instance_eval {undef bar}

#=> singleton method "foo" was undefined
# singleton method...
..."bar" was undefined
//}

@see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef...
<< 1 2 3 ... > >>