72件ヒット
[1-72件を表示]
(0.090秒)
別のキーワード
ライブラリ
- ビルトイン (72)
モジュール
- Enumerable (24)
キーワード
- grep (24)
- methods (12)
-
private
_ instance _ methods (12) -
undef
_ method (12)
検索結果
先頭5件
-
Module
# instance _ methods(inherited _ too = true) -> [Symbol] (18186.0) -
そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。
...[ruby]{
class Foo
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() 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]
[:public_foo]
[:private_foo]
[:protected_foo]
//emlist[例2][ruby]{
class Bar
private; def private_foo() end
protected; def protected_foo() end
public;......r.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(t... -
Module
# private _ instance _ methods(inherited _ too = true) -> [Symbol] (6126.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]
//}... -
Object
# methods(include _ inherited = true) -> [Symbol] (43.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...なっています。
@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。
//emlist[例1][ruby]{
class Parent
private; def private_parent() end
protected; def protected_parent() end
public; def public_parent() end
end
class Fo......:public_singleton]
[:public_singleton, :public_foo]
[:private_singleton, :private_foo]
[:protected_singleton, :protected_foo]
//}
//emlist[例2][ruby]{
# あるオブジェクトの応答できるメソッドの一覧を得る。
# 自身のクラスの親クラスのインスタンスメソッ......obj.methods(true) - Object.instance_methods(true)
p obj.public_methods(true) - Object.public_instance_methods(true)
p obj.private_methods(true) - Object.private_instance_methods(true)
p obj.protected_methods(true) - Object.protected_instance_methods(true)
# 実行結果
[:protected_s... -
Module
# undef _ method(*name) -> self (37.0) -
このモジュールのインスタンスメソッド name を未定義にします。
...て、
「未定義」は「メソッドの削除」とは区別されます。
以下のコード例を参照してください。
//emlist[例][ruby]{
class A
def ok
puts 'A'
end
end
class B < A
def ok
puts 'B'
end
end
B.new.ok # => B
# undef_method の場合はスーパーク......t[例][ruby]{
module M1
def foo
end
def self.moo
undef foo
end
end
M1.instance_methods false #=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.instance_methods false #=> ["foo"]
M2.moo
M2.instance_methods false... -
Enumerable
# grep(pattern) -> [object] (13.0) -
pattern === item が成立する要素を全て含んだ配列を返します。
...返します。
@param pattern 「===」メソッドを持つオブジェクトを指定します。
//emlist[例][ruby]{
['aa', 'bb', 'cc', 'dd', 'ee'].grep(/[bc]/) # => ["bb", "cc"]
Array.instance_methods.grep(/gr/) # => [:grep, :group_by]
//}
@see Enumerable#select
@see Enumerable#grep_v... -
Enumerable
# grep(pattern) {|item| . . . } -> [object] (13.0) -
pattern === item が成立する要素を全て含んだ配列を返します。
...返します。
@param pattern 「===」メソッドを持つオブジェクトを指定します。
//emlist[例][ruby]{
['aa', 'bb', 'cc', 'dd', 'ee'].grep(/[bc]/) # => ["bb", "cc"]
Array.instance_methods.grep(/gr/) # => [:grep, :group_by]
//}
@see Enumerable#select
@see Enumerable#grep_v...