るりまサーチ

最速Rubyリファレンスマニュアル検索!
134件ヒット [1-100件を表示] (0.057秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

検索結果

<< 1 2 > >>

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

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

...Object#methods

//emlist[例1][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; de...
...stance_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(true)...

Module#private_instance_methods(inherited_too = true) -> [Symbol] (35145.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] (35121.0)

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

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

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


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

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

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

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

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


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

Module#ruby2_keywords(method_name, ...) -> nil (29052.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...e method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword arguments, the final hash argument is marked...
...eyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed through the method to
other methods.

This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

This method wi...
...st in Ruby versions
before 2.7, check that the module responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module
Mod
def foo(meth, *args, &block)
send(:...

絞り込み条件を変える

Module#undef_method(*name) -> self (29038.0)

このモジュールのインスタンスメソッド name を未定義にします。

...][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 #=>...

Object#methods(include_inherited = true) -> [Symbol] (26205.0)

そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。

...の名前を返します。

ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。


@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。

//emlist[例1][ruby]{
class Parent
private; def...
...eton() end
end

# あるオブジェクトの応答できるメソッドの一覧を得る。
p obj.methods(false)
p obj.public_methods(false)
p obj.private_methods(false)
p obj.protected_methods(false)

# 実行結果
[:protected_singleton, :public_singleton]
[:public_singleton, :public_foo]
[:p...
...ている。
p 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)

# 実行結...

Refinement#import_methods(*modules) -> self (14245.0)

モジュールからメソッドをインポートします。

...モジュールからメソッドをインポートします。

Module
#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。

メソッドをコピーするため、Rubyコードで...
...てください。

//emlist[][ruby]{
module
StrUtils
def indent(level)
' ' * level + self
end
end

module
M
refine String do
import_methods StrUtils
end
end

using M
p "foo".indent(3) # => " foo"

module
M
refine String do
import_methods Enumerable
# Can't import method...

Object#singleton_methods(inherited_too = true) -> [Symbol] (14163.0)

そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。

...の場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。

singleton_methods(false) は、Object#methods(false) と同じです。

@param inherited_too 継承した特異メソッドを含める場合は真を、...
...rent)

class <<Foo
private; def private_class_foo() end
protected; def protected_class_foo() end
public; def public_class_foo() end
end

module
Bar
private; def private_bar() end
protected; def protected_bar() end
public; def public_bar() end
end

obj = Foo.new
class <<obj...
...c; def public_self() end
end

# あるオブジェクトの特異メソッドの一覧を得る。
p obj.singleton_methods(false)
p obj.methods(false)
p Foo.singleton_methods(false)

#実行結果

[:protected_self, :public_self]
[:protected_self, :public_self]
[:protected_class_foo, :public_c...

Object#private_methods(include_inherited = true) -> [Symbol] (14127.0)

そのオブジェクトが理解できる private メソッド名の一覧を返します。

...が理解できる private メソッド名の一覧を返します。

@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。


@see Module#private_instance_methods,Object#methods,Object#singleton_methods...

絞り込み条件を変える

Object#protected_methods(include_inherited = true) -> [Symbol] (14127.0)

そのオブジェクトが理解できる protected メソッド名の一覧を返します。

...解できる protected メソッド名の一覧を返します。

@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。


@see Module#protected_instance_methods,Object#methods,Object#singleton_methods...
<< 1 2 > >>