527件ヒット
[1-100件を表示]
(0.102秒)
ライブラリ
- ビルトイン (252)
- forwardable (48)
-
rdoc
/ context (12) - singleton (24)
クラス
- Array (24)
- BasicObject (36)
- Hash (24)
- Module (72)
- Object (84)
-
RDoc
:: Context (12)
モジュール
- SingleForwardable (48)
- Singleton (12)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - Numeric (12)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
- clone (24)
-
def
_ delegator (12) -
def
_ delegators (12) -
def
_ single _ delegator (12) -
def
_ single _ delegators (12) -
define
_ singleton _ method (24) - dup (24)
-
initialize
_ copy (12) - instance (12)
-
irb
/ completion (12) - method (12)
-
method
_ added (12) -
method
_ removed (12) -
method
_ undefined (12) -
private
_ class _ method (24) -
private
_ methods (12) -
rb
_ define _ singleton _ method (12) -
rb
_ obj _ singleton _ methods (12) -
rb
_ singleton _ class (12) -
rb
_ singleton _ class _ attached (12) -
rb
_ singleton _ class _ clone (12) -
rb
_ singleton _ class _ new (12) -
rdoc
/ parser / ruby (12) -
ruby 1
. 8 . 3 feature (12) -
set
_ visibility _ for (12) -
singleton
_ class (12) -
singleton
_ class? (12) -
singleton
_ method (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) - クラス/メソッドの定義 (12)
検索結果
先頭5件
-
Singleton (38070.0)
-
Singleton パターンを提供するモジュールです。
...Singleton パターンを提供するモジュールです。
Mix-in により singleton パターンを提供します。
Singleton モジュールを include することにより、クラスは
高々ひとつのインスタンスしか持たないことが保証されます。
Singleton を M......instance はその唯一のインスタンスを返します。
new は private メソッドに移され、外部から呼び出そうとするとエラーになります。
=== サンプルコード
require 'singleton'
class SomeSingletonClass
include Singleton
#....
end
a = So......meSingletonClass.instance
b = SomeSingletonClass.instance # a and b are same object
p [a,b] # => [#<SomeSingletonClass:0x0000562e6e18ddd0>, #<SomeSingletonClass:0x0000562e6e18ddd0>]
a = SomeSingletonClass.new # => NoMethodError (private method `new' called for SomeSingletonClass:Class)... -
Singleton
. instance -> object (27112.0) -
そのクラスの唯一のインスタンスを返します。 最初に呼ばれたときはそのインスタンスを生成します。
...そのクラスの唯一のインスタンスを返します。
最初に呼ばれたときはそのインスタンスを生成します。
Singleton を include したクラスで定義されますので、
正確には Singleton モジュールのメソッドではありません。... -
Object
# singleton _ class -> Class (12319.0) -
レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。
...e か false なら、それぞれ NilClass, TrueClass,
FalseClass を返します。
@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。
//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:Stri......ng>
nil.singleton_class #=> NilClass
//}
@see Object#class... -
VALUE rb
_ singleton _ class(VALUE obj) (12300.0) -
obj に特異クラスを導入し、その特異クラスを返します。 すでに特異クラスが導入されているときはそれをそのまま返します。
obj に特異クラスを導入し、その特異クラスを返します。
すでに特異クラスが導入されているときはそれをそのまま返します。
obj が特異メソッドを定義できない型のオブジェクトである
ときは例外 TypeError を発生します。 -
VALUE rb
_ singleton _ class _ clone(VALUE klass) (12300.0) -
特異クラス klass を clone して返します。 klass が特異クラスでないときはただ klass を返します。
...特異クラス klass を clone して返します。
klass が特異クラスでないときはただ klass を返します。... -
VALUE rb
_ singleton _ class _ new(VALUE super) (12300.0) -
super をスーパークラスとする特異クラスを生成し、返します。
super をスーパークラスとする特異クラスを生成し、返します。 -
void rb
_ singleton _ class _ attached(VALUE klass , VALUE obj) (12300.0) -
特異クラス klass にその唯一のインスタンス obj を結びつけます。
...特異クラス klass にその唯一のインスタンス obj を結びつけます。... -
BasicObject
# singleton _ method _ added(name) -> object (12231.0) -
特異メソッドが追加された時にインタプリタから呼び出されます。
...thod_addedを使います。
@param name 追加されたメソッド名が Symbol で渡されます。
//emlist[例][ruby]{
class Foo
def singleton_method_added(name)
puts "singleton method \"#{name}\" was added"
end
end
obj = Foo.new
def obj.foo
end
#=> singleton method "foo" was added......//}
@see Module#method_added,BasicObject#singleton_method_removed,BasicObject#singleton_method_undefined... -
Module
# singleton _ class? -> bool (12219.0) -
self が特異クラスの場合に true を返します。そうでなければ false を返し ます。
...self が特異クラスの場合に true を返します。そうでなければ false を返し
ます。
//emlist[例][ruby]{
class C
end
C.singleton_class? # => false
C.singleton_class.singleton_class? # => true
//}...