815件ヒット
[1-100件を表示]
(0.063秒)
別のキーワード
種類
- インスタンスメソッド (606)
- モジュール関数 (123)
- クラス (44)
- 特異メソッド (42)
クラス
- BasicObject (66)
- Enumerator (58)
- Method (182)
- Module (100)
- NoMethodError (17)
- Object (121)
- Proc (11)
- Regexp (22)
- Thread (11)
- TracePoint (39)
- UnboundMethod (21)
キーワード
- === (7)
- BasicObject (11)
- Proc (11)
- UnboundMethod (11)
- [] (22)
-
alias
_ method (11) - arity (11)
- bind (11)
-
bind
_ call (10) - call (22)
-
callee
_ id (11) -
class
_ exec (11) - clone (11)
-
define
_ method (22) - dump (22)
- each (44)
-
enum
_ for (22) - fail (33)
- inspect (11)
-
instance
_ eval (22) -
instance
_ method (11) - lambda (17)
- lambda? (11)
- match (22)
-
method
_ id (11) -
method
_ missing (11) - methods (11)
-
module
_ exec (11) - name (11)
-
original
_ name (11) - owner (11)
- parameters (17)
- private (23)
- proc (18)
- raise (33)
- receiver (11)
-
respond
_ to? (11) -
respond
_ to _ missing? (11) - send (22)
-
singleton
_ method (11) -
singleton
_ method _ added (11) -
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11) -
source
_ location (11) -
super
_ method (10) -
to
_ enum (22) -
to
_ proc (11) -
to
_ s (11) - unbind (11)
-
undef
_ method (11)
検索結果
先頭5件
- Method
- Method
# super _ method -> Method | nil - NoMethodError
. new(error _ message = "" , name = nil , args = nil , priv = false) -> NoMethodError - NoMethodError
. new(error _ message = "" , name = nil , args = nil , priv = false , receiver:) -> NoMethodError - NoMethodError
. new(error _ message = "" , name = nil , args = nil) -> NoMethodError
-
Method (38126.0)
-
Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。
...ject#method によりオブジェクト化され
たメソッドオブジェクトのクラスです。
メソッドの実体(名前でなく)とレシーバの組を封入します。
Proc オブジェクトと違ってコンテキストを保持しません。
=== Proc との差
Method は......は使い捨てに向き、Method は何度も繰り返し生成する
場合に向くと言えます。また内包するコードの大きさという点では
Proc は小規模、Method は大規模コードに向くと言えます。
既存のメソッドを Method オブジェクト化する......with arg #{arg}"
end
end
m = Foo.new.method(:foo)
p m # => #<Method: Foo#foo>
p m.call(1) # => "foo called with arg 1"
//}
名前のないメソッド(の代わり)が必要なら Proc を使うと良い。
//emlist[例][ruby]{
pr = Proc.new {|arg|
"proc called with arg #{ar... -
Method
# super _ method -> Method | nil (27286.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"
//}... -
NoMethodError
. new(error _ message = "" , name = nil , args = nil , priv = false) -> NoMethodError (21210.0) -
例外オブジェクトを生成して返します。
...形式 (関数形式(レシーバを省略した形式)) で呼ばれたかどうかを指定します
@param receiver 原因となったメソッド呼び出しのレシーバです
例:
nom = NoMethodError.new("message", "foo", [1,2,3])
p nom.name
p nom.args
# => "foo"
[1, 2, 3]... -
NoMethodError
. new(error _ message = "" , name = nil , args = nil , priv = false , receiver:) -> NoMethodError (21210.0) -
例外オブジェクトを生成して返します。
...形式 (関数形式(レシーバを省略した形式)) で呼ばれたかどうかを指定します
@param receiver 原因となったメソッド呼び出しのレシーバです
例:
nom = NoMethodError.new("message", "foo", [1,2,3])
p nom.name
p nom.args
# => "foo"
[1, 2, 3]... -
NoMethodError
. new(error _ message = "" , name = nil , args = nil) -> NoMethodError (21209.0) -
例外オブジェクトを生成して返します。
...param error_message エラーメッセージを表す文字列です
@param name 未定義だったシンボルです
@param args メソッド呼び出しに使われた引数です
例:
nom = NoMethodError.new("message", "foo", [1,2,3])
p nom.name
p nom.args
# => "foo"
[1, 2, 3]... -
NoMethodError
. new(error _ message = "" , name = nil , args = nil , priv = false) -> NoMethodError (21209.0) -
例外オブジェクトを生成して返します。
...に使われた引数です
@param priv private なメソッドを呼び出せる形式 (関数形式(レシーバを省略した形式)) で呼ばれたかどうかを指定します
例:
nom = NoMethodError.new("message", "foo", [1,2,3])
p nom.name
p nom.args
# => "foo"
[1, 2, 3]... -
Method
# inspect -> String (21152.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> (形式... -
Method
# to _ s -> String (21152.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> (形式... -
Method
# inspect -> String (21146.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 (21146.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
# unbind -> UnboundMethod (21144.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
# clone -> Method (21143.0) -
自身を複製した Method オブジェクトを作成して返します。
...自身を複製した Method オブジェクトを作成して返します。
//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.call # => "foo"
m.clone # => #<Method: Foo#foo>
m.clone.call # => "foo"
//}... -
Method
# arity -> Integer (21068.0) -
メソッドが受け付ける引数の数を返します。
...end
c = C.new
p c.method(:u).arity #=> 0
p c.method(:v).arity #=> 1
p c.method(:w).arity #=> -1
p c.method(:x).arity #=> 2
p c.method(:y).arity #=> -3
p c.method(:z).arity #=> -3
s = "xyz"
s.method(:size).arity #=> 0
s.method(:replace).arity #=> 1
s.method(:squeeze).......arity #=> -1
s.method(:count).arity #=> -1
//}... -
Method
# parameters -> [object] (21048.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 Pro...