るりまサーチ

最速Rubyリファレンスマニュアル検索!
60件ヒット [1-60件を表示] (0.022秒)
トップページ > クエリ:Method[x] > クエリ:methods[x] > クラス:Module[x]

別のキーワード

  1. irb/input-method gets
  2. irb/input-method new
  3. _builtin define_method
  4. irb/input-method encoding
  5. irb/input-method readable_atfer_eof?

検索結果

Module#instance_methods(inherited_too = true) -> [Symbol] (12280.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] (12226.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] (12214.0)

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

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

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


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

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

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

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

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


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

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

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

...k
puts 'B'
end
end

B.new.ok # => B

# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.ok # => NameError

# remove_method の場合はスーパークラスに同名のメソ...
...ss B
remove_method :ok
end
B.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。

//emlist[例][ruby]{
module
M1
def foo
end
def self.moo
undef foo
end
end
M1.instance_methods false #=> ["f...
...oo"]
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 #=> []
//}...

絞り込み条件を変える

Module#ruby2_keywords(method_name, ...) -> nil (282.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.

...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 argument...
...other 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.

This should only be used for methods that delegate keywords to another
method
, an...
....7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist 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 ch...