55件ヒット
[1-55件を表示]
(0.049秒)
クラス
- BasicObject (33)
- Object (22)
キーワード
-
singleton
_ method _ added (11) -
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11)
検索結果
先頭5件
-
Object
# singleton _ method(name) -> Method (18127.0) -
オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。
...st[][ruby]{
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) #... -
Object
# singleton _ methods(inherited _ too = true) -> [Symbol] (6228.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 _ removed(name) -> object (6139.0) -
特異メソッドが Module#remove_method に より削除された時にインタプリタから呼び出されます。
...][ruby]{
class Foo
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,Basic... -
BasicObject
# singleton _ method _ undefined(name) -> object (6139.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...ソッド名が Symbol で渡されます。
//emlist[例][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... -
BasicObject
# singleton _ method _ added(name) -> object (6133.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...