るりまサーチ

最速Rubyリファレンスマニュアル検索!
276件ヒット [101-200件を表示] (0.036秒)
トップページ > クエリ:ruby[x] > クエリ:instance_method[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. csv instance
  2. prime instance
  3. _builtin instance_eval
  4. syslog instance
  5. basicobject instance_eval

ライブラリ

クラス

キーワード

検索結果

<< < 1 2 3 > >>

UnboundMethod#owner -> Class | Module (25.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(obj) -> Method (19.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 のインスタン...
...のインスタンスメソッドの UnboundMethod の場合
module Foo
def foo
"foo"
end
end

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

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method...

Method#parameters -> [object] (13.0)

Method オブジェクトの引数の情報を返します。

...た残りのキーワード引数
: :block
& で指定されたブロック引数

//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, :...

Module#define_method(name) { ... } -> Symbol (13.0)

インスタンスメソッド name を定義します。

...

@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...

Module#define_method(name, method) -> Symbol (13.0)

インスタンスメソッド name を定義します。

...

@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...

絞り込み条件を変える

Module#method_added(name) -> () (13.0)

メソッド name が追加された時にインタプリタがこのメソッドを呼び出します。

...加されたメソッドの名前が Symbol で渡されます。

//emlist[例][ruby]{
class Foo
def Foo.method_added(name)
puts "method \"#{name}\" was added"
end

def foo
end
define_method :bar, instance_method(:foo)
end

# => method "foo" was added
# method "bar" was added
//}...

Object#method(name) -> Method (13.0)

オブジェクトのメソッド name をオブジェクト化した Method オブジェクトを返します。

...ror 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
me = -365.method(:abs)
p me #=> #<Method: Integer#abs>
p me.call #=> 365
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#singleton_method...

Object#public_method(name) -> Method (13.0)

オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。

...vate メソッド名を引数として与えると発生します。

//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}

@see Object#method,Object#public_send,Module#public_instance_method...

Object#singleton_method(name) -> Method (13.0)

オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。

...はStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end

k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}...
..."
end
m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#method...
<< < 1 2 3 > >>