225件ヒット
[1-100件を表示]
(0.039秒)
別のキーワード
種類
- インスタンスメソッド (154)
- 関数 (33)
- 文書 (27)
- クラス (11)
ライブラリ
- ビルトイン (165)
クラス
- Module (99)
- Object (33)
- UnboundMethod (22)
キーワード
-
NEWS for Ruby 2
. 7 . 0 (5) - UnboundMethod (11)
- bind (11)
-
define
_ method (22) -
instance
_ methods (11) - method (11)
-
method
_ added (11) - owner (11)
-
private
_ instance _ methods (11) -
protected
_ instance _ methods (11) -
public
_ instance _ method (11) -
public
_ instance _ methods (11) -
public
_ method (11) -
rb
_ class _ instance _ methods (11) -
rb
_ class _ private _ instance _ methods (11) -
rb
_ class _ protected _ instance _ methods (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) -
singleton
_ method (11)
検索結果
先頭5件
-
Module
# instance _ method(name) -> UnboundMethod (39137.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 (27131.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
# private _ instance _ methods(inherited _ too = true) -> [Symbol] (27118.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] (27106.0) -
そのモジュールで定義されている protected メソッド名 の一覧を配列で返します。
...そのモジュールで定義されている protected メソッド名
の一覧を配列で返します。
@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。
@see Object#protected_methods, Module#instance_methods... -
Module
# public _ instance _ methods(inherited _ too = true) -> [Symbol] (27106.0) -
そのモジュールで定義されている public メソッド名 の一覧を配列で返します。
...そのモジュールで定義されている public メソッド名
の一覧を配列で返します。
@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。
@see Object#public_methods, Module#instance_methods... -
Module
# instance _ methods(inherited _ too = true) -> [Symbol] (27100.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
# define _ method(name) { . . . } -> Symbol (21006.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 (21006.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) -> () (21006.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
//}... -
VALUE rb
_ class _ instance _ methods(int argc , VALUE *argv , VALUE mod) (6116.0) -
Module#instance_methods の実体。 モジュール mod に定義されている public メソッド名の リストを文字列の配列で返します。
...
Module#instance_methods の実体。
モジュール mod に定義されている public メソッド名の
リストを文字列の配列で返します。...