461件ヒット
[1-100件を表示]
(0.053秒)
ライブラリ
- ビルトイン (397)
クラス
- Method (83)
- Module (48)
- Object (24)
- Proc (3)
- UnboundMethod (179)
モジュール
- Marshal (24)
オブジェクト
- main (24)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - == (12)
- === (6)
-
NEWS for Ruby 3
. 1 . 0 (4) - [] (6)
- arity (12)
- bind (12)
-
bind
_ call (12) - call (12)
- clone (12)
-
define
_ method (48) -
define
_ singleton _ method (24) - dump (24)
- eql? (12)
- hash (12)
- inspect (24)
-
instance
_ method (12) - name (12)
-
original
_ name (24) - owner (12)
- parameters (15)
-
public
_ instance _ method (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
source
_ location (12) -
super
_ method (22) -
to
_ s (24) -
umethod
_ bind (12) - unbind (12)
検索結果
先頭5件
-
UnboundMethod (44018.0)
-
レシーバを持たないメソッドを表すクラスです。 呼び出すためにはレシーバにバインドする必要があります。
...があります。
Module#instance_method や
Method#unbind により生成し、後で
UnboundMethod#bind によりレシーバを
割り当てた Method オブジェクトを作ることができます。
//emlist[例: Method クラスの冒頭にある例を UnboundMethod で書くと以下の......ss Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end
# 任意のキーとメソッドの関係をハッシュに保持しておく
# レシーバの情報がここにはないことに注意
methods = {1 => Foo.instance_method(:foo),
2 => Foo.instance_method(:bar).......instance_method(:baz)}
# キーを使って関連するメソッドを呼び出す
# レシーバは任意(Foo クラスのインスタンスでなければならない)
p methods[1].bind(Foo.new).call # => "foo"
p methods[2].bind(Foo.new).call # => "bar"
p methods[3].bind(Foo.new).call... -
UnboundMethod
# super _ method -> UnboundMethod | nil (27317.0) -
self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ クトにして返します。
...self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ
クトにして返します。
@see Method#super_method... -
UnboundMethod
# bind(obj) -> Method (27142.0) -
self を obj にバインドした Method オブジェクトを生成して返します。
...thod オブジェクトを生成して返します。
@param obj 自身をバインドしたいオブジェクトを指定します。ただしバインドできるのは、
生成元のクラスかそのサブクラスのインスタンスのみです。
@raise TypeError objがbindで......の UnboundMethod の場合
class Foo
def foo
"foo"
end
end
# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>
# Foo のインスタンスをレシーバとする Method オブジェクトを生成
p m.bind(Foo.new) # => #<Method: Foo......Method
class Bar < Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
# モジュールのインスタンスメソッドの UnboundMethod の場合
module Foo
def foo
"foo"
end
end
# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#f... -
UnboundMethod
# bind _ call(recv , *args) -> object (27106.0) -
self を recv に bind して args を引数として呼び出します。
...self を recv に bind して args を引数として呼び出します。
self.bind(recv).call(*args) と同じ意味です。
//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}
@see UnboundMethod#bind, Method#call... -
UnboundMethod
# bind _ call(recv , *args) { . . . } -> object (27106.0) -
self を recv に bind して args を引数として呼び出します。
...self を recv に bind して args を引数として呼び出します。
self.bind(recv).call(*args) と同じ意味です。
//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}
@see UnboundMethod#bind, Method#call... -
UnboundMethod
# clone -> UnboundMethod (24217.0) -
自身を複製した UnboundMethod オブジェクトを作成して返します。
...自身を複製した UnboundMethod オブジェクトを作成して返します。
//emlist[例][ruby]{
a = String.instance_method(:size)
b = a.clone
a == b # => true
//}... -
UnboundMethod
# owner -> Class | Module (24100.0) -
このメソッドが定義されている class か module を返します。
...このメソッドが定義されている class か module を返します。
//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}... -
UnboundMethod
# parameters -> [object] (24016.0) -
UnboundMethod オブジェクトの引数の情報を返します。
...
UnboundMethod オブジェクトの引数の情報を返します。
詳しくは Method#parameters を参照してください。
@see Proc#parameters, Method#parameters... -
UnboundMethod
# arity -> Integer (24006.0) -
メソッドが受け付ける引数の数を返します。
...ass C
def one; end
def two(a); end
def three(*a); end
def four(a, b); end
def five(a, b, *c); end
def six(a, b, *c, &d); end
end
p C.instance_method(:one).arity #=> 0
p C.instance_method(:two).arity #=> 1
p C.instance_method(:three).arity #=> -1
p C.instance_method(:fou......).arity #=> 2
p C.instance_method(:five).arity #=> -3
p C.instance_method(:six).arity #=> -3
String.instance_method(:size).arity #=> 0
String.instance_method(:replace).arity #=> 1
String.instance_method(:squeeze).arity #=> -1
String.instance_method(:count).arity #=> -1
//}... -
UnboundMethod
# inspect -> String (24006.0) -
self を読みやすい文字列として返します。
...self を読みやすい文字列として返します。
詳しくは Method#inspect を参照してください。
//emlist[例][ruby]{
String.instance_method(:count).inspect # => "#<UnboundMethod: String#count>"
//}
@see Method#inspect...