るりまサーチ

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

別のキーワード

  1. csv instance
  2. _builtin instance_eval
  3. singleton instance
  4. basicobject instance_eval
  5. forwardable instance_delegate

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 > >>

UnboundMethod (38048.0)

レシーバを持たないメソッドを表すクラスです。 呼び出すためにはレシーバにバインドする必要があります。

...あります。

Module#instance_method
Method#unbind により生成し、後で
UnboundMethod
#bind によりレシーバを
割り当てた Method オブジェクトを作ることができます。

//emlist[例: Method クラスの冒頭にある例を UnboundMethod で書くと以下のよ...
...保持しておく
# レシーバの情報がここにはないことに注意
methods = {1 => Foo.instance_method(:foo),
2 => Foo.instance_method(:bar),
3 => Foo.instance_method(:baz)}

# キーを使って関連するメソッドを呼び出す
# レシーバは任意(Foo ク...
...# => "baz"
//}

//emlist[例: 以下はメソッドの再定義を UnboundMethod を使って行う方法です。普通は alias や super を使います。][ruby]{
class Foo
def foo
p :foo
end
@@orig_foo = instance_method :foo
def foo
p :bar
@@orig_foo.bind(self).call
end
en...

UnboundMethod#clone -> UnboundMethod (21123.0)

自身を複製した UnboundMethod オブジェクトを作成して返します。

...自身を複製した UnboundMethod オブジェクトを作成して返します。

//emlist[例][ruby]{
a = String.instance_method(:size)
b = a.clone

a == b # => true
//}...

UnboundMethod#arity -> Integer (21060.0)

メソッドが受け付ける引数の数を返します。

...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(:four).arity #=> 2
p C.instance_method(:five).arity #=> -3
p C.instance_method(:six).arity #=> -3


String.instance_method(:size).arit...
...y #=> 0
String.instance_method(:replace).arity #=> 1
String.instance_method(:squeeze).arity #=> -1
String.instance_method(:count).arity #=> -1
//}...

UnboundMethod#bind(obj) -> Method (21054.0)

self を obj にバインドした Method オブジェクトを生成して返します。

...ます

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo のインスタンスをレシーバとする Method オ...
...ethod: Bar(Foo)#foo>


# モジュールのインスタンスメソッドの UnboundMethod の場合
module Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタ...
...ンスをレシーバと
# する Method オブジェクトを生成
class Bar
include Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}

@see UnboundMethod#bind_call...

UnboundMethod#==(other) -> bool (21018.0)

自身と other が同じクラスあるいは同じモジュールの同じメソッドを表す場合に true を返します。そうでない場合に false を返します。

...@param other 自身と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
a = String.instance_method(:size)
b = String.instance_method(:size)
p a == b #=> true

c = Array.instance_method(:size)
p a == c #=> false
//}...

絞り込み条件を変える

UnboundMethod#eql?(other) -> bool (21018.0)

自身と other が同じクラスあるいは同じモジュールの同じメソッドを表す場合に true を返します。そうでない場合に false を返します。

...@param other 自身と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
a = String.instance_method(:size)
b = String.instance_method(:size)
p a == b #=> true

c = Array.instance_method(:size)
p a == c #=> false
//}...

UnboundMethod#owner -> Class | Module (21018.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#bind_call(recv, *args) -> object (21012.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 (21012.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#inspect -> String (21012.0)

self を読みやすい文字列として返します。

...self を読みやすい文字列として返します。

詳しくは Method#inspect を参照してください。

//emlist[例][ruby]{
String.instance_method(:count).inspect # => "#<UnboundMethod: String#count>"
//}

@see Method#inspect...

絞り込み条件を変える

UnboundMethod#source_location -> [String, Integer] | nil (21012.0)

ソースコードのファイル名と行番号を配列で返します。

...(つまりネイティブ
である)場合は nil を返します。

//emlist[例][ruby]{
require 'time'

Time.instance_method(:zone).source_location # => nil
Time.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/ruby/2.4.0/time.rb", 654]
//}

@see Pro...
<< 1 2 3 > >>