るりまサーチ

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

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

検索結果

Object#singleton_method(name) -> Method (18125.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] (6226.0)

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

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

singleton_method
s(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 (6137.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 (6137.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 (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...

絞り込み条件を変える

NEWS for Ruby 2.1.0 (6072.0)

NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.1.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...

* Kernel
* 追加: Kernel#singleton_method(Object#singleton_method)

* Module
* 追加: Module#using, which activates refinements of the specified module only
in the current class or module definition.
* 追加: Module#singleton_class? レシーバーが特異クラスで...
...の外側には影響を与えないという意味です。
以下のコードは Foo#foo をプライベートにしません。
//emlist{
class
Foo
eval "private"
def foo
end
end
//}

* Object#untrusted?,Object#untrust,Object#trust
* これらのメソッドは...

NEWS for Ruby 2.3.0 (6030.0)

NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.3.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...全な文字があると例外が発生するようになりました。
11444

* Module
* Module#define_method と Object#define_singleton_method
メソッド本体(Procオブジェクト、Methodオブジェクト、またはブロック )が必須になりました。...
...bjectSpace (objspace)
* ObjectSpace.#count_symbols を追加。
* ObjectSpace.#count_imemo_objects を追加。
* ObjectSpace.#internal_class_of を追加。
* ObjectSpace.#internal_super_of を追加。

* OpenSSL
* OpenSSL::SSL::SSLSocket#accept_nonblock と
OpenSSL::SS...

1.6.8から1.8.0への変更点(まとめ) (4650.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...よくわかりません(^^;

class
<< Object
p [self.id, self]
class
<< self
p [self.id, self]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09...
...(^^;;

class
<< Object.new
class
<< self.superclass
p [self.id, self]
end
class
<< self
p [self.superclass.id, self.superclass]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]...
...e_get>)) [new]
: ((<Object#instance_variable_set|Object/instance_variable_set>)) [new]

追加

: ((<Object#object_id|Object/object_id>)) [new]

追加 (Object#id は、obsolete)

: ((<Object#singleton_method_removed|Object/singleton_method_removed>)) [new]
: ((<Object#singleton_method_undefined...

クラス/メソッドの定義 (352.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined

===[a:class] クラス定義

//emlist[例][ruby]{
class
Foo < S...
...uper
def test
# ...
end
# ...
end
//}

文法:

class
識別子 [`<' superclass ]
式..
end

文法:

class
識別子 [`<' superclass ]
式..
[rescue [error_type,..] [=> evar] [then]
式..]..
[else...
...
# (Net のインスタンスがない。Net を include できるなどのため)
module Net
class
HTTP
end
class
FTP
end
end

obj = Net::HTTP.new

# あるいは

include Net
obj = HTTP.new

# 以下のような使い方は組み込みのクラスにも見られる
# 利用者は File::...