163件ヒット
[1-100件を表示]
(0.158秒)
ライブラリ
- ビルトイン (163)
キーワード
- == (11)
- arity (11)
- bind (11)
-
bind
_ call (10) - clone (11)
- eql? (11)
- hash (11)
- inspect (11)
- name (11)
-
original
_ name (11) - owner (11)
- parameters (11)
-
source
_ location (11) -
super
_ method (10) -
to
_ s (11)
検索結果
先頭5件
-
UnboundMethod
# original _ name -> Symbol (9202.0) -
オリジナルのメソッド名を返します。
...オリジナルのメソッド名を返します。
//emlist[例][ruby]{
class C
def foo; end
alias bar foo
end
C.instance_method(:bar).original_name # => :foo
//}
@see Method#original_name... -
UnboundMethod
# bind(obj) -> Method (6102.0) -
self を obj にバインドした Method オブジェクトを生成して返します。
...objがbindできないオブジェクトである場合に発生します
//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end
end
# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#fo......p m.bind(Foo.new) # => #<Method: Foo#foo>
# Foo のサブクラス Bar のインスタンスをレシーバとする Method
class Bar < Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
# モジュールのインスタンスメソッドの UnboundMethod の場合......"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)... -
UnboundMethod
# bind _ call(recv , *args) -> object (6102.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 (6102.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 (6102.0) -
自身を複製した UnboundMethod オブジェクトを作成して返します。
...自身を複製した UnboundMethod オブジェクトを作成して返します。
//emlist[例][ruby]{
a = String.instance_method(:size)
b = a.clone
a == b # => true
//}... -
UnboundMethod
# inspect -> String (6102.0) -
self を読みやすい文字列として返します。
...self を読みやすい文字列として返します。
詳しくは Method#inspect を参照してください。
//emlist[例][ruby]{
String.instance_method(:count).inspect # => "#<UnboundMethod: String#count>"
//}
@see Method#inspect... -
UnboundMethod
# name -> Symbol (6102.0) -
このメソッドの名前を返します。
...このメソッドの名前を返します。
//emlist[例][ruby]{
a = String.instance_method(:size)
a.name # => :size
//}... -
UnboundMethod
# owner -> Class | Module (6102.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
# source _ location -> [String , Integer] | nil (6102.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 Proc#source_location, Method#source_location... -
UnboundMethod
# arity -> Integer (3102.0) -
メソッドが受け付ける引数の数を返します。
...lass 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(:fo......ur).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
# hash -> Integer (3102.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
//emlist[例][ruby]{
a = method(:==).unbind
b = method(:eql?).unbind
p a.eql? b # => true
p a.hash == b.hash # => true
p [a, b].uniq.size # => 1
//}...