るりまサーチ (Ruby 2.7.0)

最速Rubyリファレンスマニュアル検索!
9件ヒット [1-9件を表示] (0.030秒)

別のキーワード

  1. _builtin unboundmethod
  2. unboundmethod ==
  3. unboundmethod bind
  4. unboundmethod to_s
  5. unboundmethod name

キーワード

検索結果

Method#unbind -> UnboundMethod (382.0)

self のレシーバとの関連を取り除いた UnboundMethod オブ ジェクトを生成して返します。

...いた UnboundMethod オブ
ジェクトを生成して返します。

//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
unbound_method = m.unbind # => #<UnboundMethod: Foo#foo>
unbound_method.bind(Foo.new) # => #<Method: Foo#foo>
//}...

Method#inspect -> String (49.0)

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

...します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ...
...klass2 は、実際にそのメソッドを定義しているクラス/モジュール名、
method
は、メソッド名を表します。

arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。

//em...
...def bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)...

Method#to_s -> String (49.0)

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

...します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ...
...klass2 は、実際にそのメソッドを定義しているクラス/モジュール名、
method
は、メソッド名を表します。

arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。

//em...
...def bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)...

Method#===(*args) -> object (31.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...せん。


@param args self に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "f...

Method#[](*args) -> object (31.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...せん。


@param args self に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "f...

絞り込み条件を変える

Method#call(*args) -> object (31.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...せん。


@param args self に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "f...

Method#call(*args) { ... } -> object (31.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...せん。


@param args self に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "f...

Method#original_name -> Symbol (31.0)

オリジナルのメソッド名を返します。

...オリジナルのメソッド名を返します。

//emlist[例][ruby]{
class C
def foo; end
alias bar foo
end
C.new.method(:bar).original_name # => :foo
//}

@see UnboundMethod#original_name...

Method#super_method -> Method | nil (31.0)

self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。

...るメソッドを Method オブジェ
クトにして返します。

@see UnboundMethod#super_method

//emlist[例][ruby]{
class Super
def foo
"superclass method"
end
end

class Sub < Super
def foo
"subclass method"
end
end

m = Sub.new.method(:foo) # => #<Method: Sub#foo>
m.call #...
...=> "subclass method"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"
//}...