別のキーワード
ライブラリ
- ビルトイン (300)
- forwardable (48)
- profiler (6)
-
rdoc
/ context (12) - singleton (48)
クラス
- Array (24)
- BasicObject (36)
- Hash (24)
- Module (72)
- Object (132)
-
RDoc
:: Context (12)
モジュール
- SingleForwardable (48)
- Singleton (36)
キーワード
-
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
. 3 . 0 (10) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - Numeric (12)
-
Profiler
_ _ (6) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
- clone (36)
-
def
_ delegator (12) -
def
_ delegators (12) -
def
_ single _ delegator (12) -
def
_ single _ delegators (12) -
define
_ singleton _ method (24) - dup (36)
-
initialize
_ copy (12) - instance (12)
-
irb
/ completion (12) - method (12)
-
method
_ added (12) -
method
_ removed (12) -
method
_ undefined (12) - methods (12)
-
private
_ class _ method (24) -
private
_ methods (12) -
protected
_ methods (12) -
public
_ 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 (12)
-
singleton
_ class (12) -
singleton
_ class? (12) -
singleton
_ method (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) -
singleton
_ methods (12) - クラス/メソッドの定義 (12)
検索結果
先頭5件
-
Singleton (38046.0)
-
Singleton パターンを提供するモジュールです。
...Singleton パターンを提供するモジュールです。
Mix-in により singleton パターンを提供します。
Singleton モジュールを include することにより、クラスは
高々ひとつのインスタンスしか持たないことが保証されます。
Singleton を M......ire '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.......new # => NoMethodError (private method `new' called for SomeSingletonClass:Class)... -
Singleton
. instance -> object (21012.0) -
そのクラスの唯一のインスタンスを返します。 最初に呼ばれたときはそのインスタンスを生成します。
...そのクラスの唯一のインスタンスを返します。
最初に呼ばれたときはそのインスタンスを生成します。
Singleton を include したクラスで定義されますので、
正確には Singleton モジュールのメソッドではありません。... -
Singleton
# clone (21000.0) -
@raise TypeError このメソッドを呼び出した場合に発生します。
@raise TypeError このメソッドを呼び出した場合に発生します。 -
Singleton
# dup (21000.0) -
@raise TypeError このメソッドを呼び出した場合に発生します。
@raise TypeError このメソッドを呼び出した場合に発生します。 -
BasicObject
# singleton _ method _ undefined(name) -> object (6137.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...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" wa......s undefined
//}
@see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef... -
Object
# singleton _ methods(inherited _ too = true) -> [Symbol] (6137.0) -
そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。
...や、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。
singleton_methods(false) は、Object#methods(false) と同じです。
@param inherited_too 継承した特異メソッドを含める場合は真を......d
public; def public_self() end
end
# あるオブジェクトの特異メソッドの一覧を得る。
p obj.singleton_methods(false)
p obj.methods(false)
p Foo.singleton_methods(false)
#実行結果
[:protected_self, :public_self]
[:protected_self, :public_self]
[:protected_class_foo,......るよう true を指定したが、
# Object のクラスメソッドは一覧から排除している。
p obj.singleton_methods(true)
p Foo.singleton_methods(true) - Object.singleton_methods(true)
#実行結果
[:protected_self, :public_self, :protected_bar, :public_bar]
[:protected_class_foo,... -
BasicObject
# singleton _ method _ added(name) -> object (6131.0) -
特異メソッドが追加された時にインタプリタから呼び出されます。
...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... -
BasicObject
# singleton _ method _ removed(name) -> object (6131.0) -
特異メソッドが Module#remove_method に より削除された時にインタプリタから呼び出されます。
...def singleton_method_removed(name)
puts "singleton method \"#{name}\" was removed"
end
end
obj = Foo.new
def obj.foo
end
class << obj
remove_method :foo
end
#=> singleton method "foo" was removed
//}
@see Module#method_removed,BasicObject#singleton_method_added,BasicObject#singleton_met... -
Module
# singleton _ class? -> bool (6119.0) -
self が特異クラスの場合に true を返します。そうでなければ false を返し ます。
...self が特異クラスの場合に true を返します。そうでなければ false を返し
ます。
//emlist[例][ruby]{
class C
end
C.singleton_class? # => false
C.singleton_class.singleton_class? # => true
//}...