ライブラリ
- ビルトイン (191)
- forwardable (44)
- profiler (6)
-
rdoc
/ context (11) - singleton (44)
クラス
- BasicObject (33)
- Module (37)
- Object (110)
-
RDoc
:: Context (11)
モジュール
- SingleForwardable (44)
- Singleton (33)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - Numeric (11)
-
Profiler
_ _ (6) - Ruby用語集 (11)
- clone (11)
-
def
_ delegator (11) -
def
_ delegators (11) -
def
_ single _ delegator (11) -
def
_ single _ delegators (11) -
define
_ singleton _ method (22) - dup (11)
-
initialize
_ copy (11) - instance (11)
-
irb
/ completion (11) -
method
_ undefined (11) - methods (11)
-
private
_ class _ method (15) -
private
_ methods (11) -
protected
_ methods (11) -
public
_ methods (11) -
rb
_ define _ singleton _ method (11) -
rb
_ obj _ singleton _ methods (11) -
rb
_ singleton _ class (11) -
rb
_ singleton _ class _ attached (11) -
rb
_ singleton _ class _ clone (11) -
rb
_ singleton _ class _ new (11) -
ruby 1
. 8 . 3 feature (11) -
set
_ visibility _ for (11) - singleton (11)
-
singleton
_ class (11) -
singleton
_ class? (11) -
singleton
_ method (11) -
singleton
_ method _ added (11) -
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11)
検索結果
先頭5件
-
Singleton (44046.0)
-
Singleton パターンを提供するモジュールです。
...Singleton パターンを提供するモジュールです。
Mix-in により singleton パターンを提供します。
Singleton モジュールを include することにより、クラスは
高々ひとつのインスタンスしか持たないことが保証されます。
Singleton を M......ix-in したクラスの
クラスメソッド instance はその唯一のインスタンスを返します。
new は private メソッドに移され、外部から呼び出そうとするとエラーになります。
=== サンプルコード
require '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 `ne... -
Singleton
. instance -> object (30112.0) -
そのクラスの唯一のインスタンスを返します。 最初に呼ばれたときはそのインスタンスを生成します。
...そのクラスの唯一のインスタンスを返します。
最初に呼ばれたときはそのインスタンスを生成します。
Singleton を include したクラスで定義されますので、
正確には Singleton モジュールのメソッドではありません。... -
Singleton
# clone (24000.0) -
@raise TypeError このメソッドを呼び出した場合に発生します。
...@raise TypeError このメソッドを呼び出した場合に発生します。... -
Singleton
# dup (24000.0) -
@raise TypeError このメソッドを呼び出した場合に発生します。
...@raise TypeError このメソッドを呼び出した場合に発生します。... -
Object
# define _ singleton _ method(symbol) { . . . } -> Symbol (18338.0) -
self に特異メソッド name を定義します。
...m symbol メソッド名を String または Symbol で指定します。
@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。
@return メソッド名を表す Symbol を返します。
//emlist[][ruby]{
class A
class <<......self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}... -
Object
# define _ singleton _ method(symbol , method) -> Symbol (18338.0) -
self に特異メソッド name を定義します。
...m symbol メソッド名を String または Symbol で指定します。
@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。
@return メソッド名を表す Symbol を返します。
//emlist[][ruby]{
class A
class <<......self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}... -
void rb
_ define _ singleton _ method(VALUE obj , const char *name , VALUE (*func)() , int argc) (18200.0) -
obj に特異メソッド name を定義します。 メソッドの実体を func に関数ポインタで与え、その関数がとる 引数のタイプを argc に渡します。argc のフォーマットに ついては rb_define_method の記述を参照してください。
...obj に特異メソッド name を定義します。
メソッドの実体を func に関数ポインタで与え、その関数がとる
引数のタイプを argc に渡します。argc のフォーマットに
ついては rb_define_method の記述を参照してください。... -
BasicObject
# singleton _ method _ undefined(name) -> object (15337.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...フックには
Module#method_undefined を使います。
@param name 未定義にされたメソッド名が Symbol で渡されます。
//emlist[例][ruby]{
class Foo
def singleton_method_undefined(name)
puts "singleton method \"#{name}\" was undefined"
end
end
obj = Foo.new
def obj.f......oo
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... -
Object
# singleton _ methods(inherited _ too = true) -> [Symbol] (12337.0) -
そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。
...そのオブジェクトに対して定義されている特異メソッド名
(public あるいは protected メソッド) の一覧を返します。
inherited_too が真のときは継承した特異メソッドを含みます。
継承した特異メソッドとは Object#extend によって追......。
singleton_methods(false) は、Object#methods(false) と同じです。
@param inherited_too 継承した特異メソッドを含める場合は真を、
そうでない場合は偽を指定します。
//emlist[例1][ruby]{
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 B... -
VALUE rb
_ obj _ singleton _ methods(int argc , VALUE *argv , VALUE obj) (12316.0) -
Object#singleton_methods の実体。 オブジェクト obj に定義されている特異メソッド名のリストを 文字列の配列で返す。
...Object#singleton_methods の実体。
オブジェクト obj に定義されている特異メソッド名のリストを
文字列の配列で返す。...