7件ヒット
[1-7件を表示]
(0.641秒)
トップページ > :Object#class > :to_regexp > :to_hash > :to_proc > :2.4.0 > :boot_defclass > :Forwardable > :create_id > クラス:Method
検索結果
先頭5件
-
Method
# [](*args) -> object (331.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...せん。
@param args self に渡される引数。
@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) # => "foo called with arg 2"
//}... -
Method
# call(*args) -> object (331.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...せん。
@param args self に渡される引数。
@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) # => "foo called with arg 2"
//}... -
Method
# call(*args) { . . . } -> object (331.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...せん。
@param args self に渡される引数。
@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) # => "foo called with arg 2"
//}... -
Method
# parameters -> [object] (325.0) -
Method オブジェクトの引数の情報を返します。
...Method オブジェクトの引数の情報を返します。
Method オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に応じた以下のような Symbol と、仮引数の名......数
//emlist[例][ruby]{
m = Class.new{define_method(:m){|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}}.instance_method(:m)
m.parameters #=> x], [:opt, :y], [:rest, :other], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
File.method(:symlink).parameters #=> req
//}
@see Proc#p... -
Method
# receiver -> object (325.0) -
このメソッドオブジェクトのレシーバを返します。
...のメソッドオブジェクトのレシーバを返します。
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.receiver # => #<Foo:0x007fb39203eb78>
m.receiver.foo(1) # => "foo called with arg 1"
//}... -
Method
# inspect -> String (130.0) -
self を読みやすい文字列として返します。
...します。
以下の形式の文字列を返します。
#<Method: klass1(klass2)#method> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュ......モジュール名、
method は、メソッド名を表します。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}
klass......が同じ場合は以下の形式になります。
#<Method: klass1#method> (形式2)
特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列... -
Method
# to _ s -> String (130.0) -
self を読みやすい文字列として返します。
...します。
以下の形式の文字列を返します。
#<Method: klass1(klass2)#method> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュ......モジュール名、
method は、メソッド名を表します。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}
klass......が同じ場合は以下の形式になります。
#<Method: klass1#method> (形式2)
特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列...