るりまサーチ

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

別のキーワード

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

検索結果

Module#instance_method(name) -> UnboundMethod (18133.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

... Module#public_instance_method, Object#method

//emlist[例][ruby]{
class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method...
...(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string.each_char {|b| Dispatcher[b].bind(self).call }
end
end

interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}...

Module#public_instance_method(name) -> UnboundMethod (6121.0)

self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...として与えると発生します。

//emlist[例][ruby]{
Kernel.public_instance_method(:object_id) #=> #<UnboundMethod: Kernel#object_id>
Kernel.public_instance_method(:p) # method `p' for module `Kernel' is private (NameError)
//}

@see Module#instance_method,Object#public_method...

Module#instance_methods(inherited_too = true) -> [Symbol] (6102.0)

そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。

...end
end

# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods(false)
p Foo.protected_instance_methods(false)

class Bar < Foo
end
//}

実行結果

[:protected_foo, :public_foo]...
...ar.instance_methods(true) - Object.instance_methods(true)
p Bar.public_instance_methods(true) - Object.public_instance_methods(true)
p Bar.private_instance_methods(true) - Object.private_instance_methods(true)
p Bar.protected_instance_methods(true) - Object.protected_instance_methods(...

Module#private_instance_methods(inherited_too = true) -> [Symbol] (6102.0)

そのモジュールで定義されている private メソッド名 の一覧を配列で返します。

...@see Object#private_methods, Module#instance_methods

//emlist[例][ruby]{
module
Foo
def foo; end
private def bar; end
end

module
Bar
include Foo

def baz; end
private def qux; end
end

Bar.private_instance_methods # => [:qux, :bar]
Bar.private_instance_methods(false) # => [:qux]
//}...

Module#protected_instance_methods(inherited_too = true) -> [Symbol] (6102.0)

そのモジュールで定義されている protected メソッド名 の一覧を配列で返します。

...そのモジュールで定義されている protected メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。


@see Object#protected_methods, Module#instance_methods...

絞り込み条件を変える

Module#public_instance_methods(inherited_too = true) -> [Symbol] (6102.0)

そのモジュールで定義されている public メソッド名 の一覧を配列で返します。

...そのモジュールで定義されている public メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。


@see Object#public_methods, Module#instance_methods...

Module#define_method(name) { ... } -> Symbol (8.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 (8.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) -> () (8.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
//}...