るりまサーチ

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

ライブラリ

検索結果

<< < ... 7 8 9 10 > >>

Module#public_method_defined?(name) -> bool (1.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。

...れば false を返します。

@param name Symbol か String を指定します。

@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
inclu...

Module#public_method_defined?(name, inherit=true) -> bool (1.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。

...たモジュールで
定義されたメソッドも対象になります。

@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
includ...

Module#rake_extension(method) { ... } -> () (1.0)

与えられたブロック内で既に存在するメソッドを再定義しようとした場合に 警告を表示します。この場合、ブロックは評価されません。

与えられたブロック内で既に存在するメソッドを再定義しようとした場合に
警告を表示します。この場合、ブロックは評価されません。

@param method ブロック内で再定義する予定のメソッド名を指定します。

例:
class String
rake_extension("xyz") do
def xyz
...
end
end
end

Module#refine(klass) { ... } -> Module (1.0)

引数 klass で指定したクラスまたはモジュールだけに対して、ブロックで指定した機能を提供で きるモジュールを定義します。定義した機能は Module#refine を使用せずに直 接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。 そのため、既存の機能を局所的に修正したい場合などに用いる事ができます。

...したクラスだけに対して、ブロックで指定した機能を提供で
きるモジュールを定義します。定義した機能は Module#refine を使用せずに直
接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。
そのた...
...ticles/0041/0041-200Special-refinement.html
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html

定義した機能は main.using, Module#using を実行した場合のみ
有効になります。

@param klass 拡張する対象のクラスを指定します。

@return ブロッ...
...モジュールだけに対して、ブロックで指定した機能を提供で
きるモジュールを定義します。定義した機能は Module#refine を使用せずに直
接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。
そのた...
...ticles/0041/0041-200Special-refinement.html
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html

定義した機能は main.using, Module#using を実行した場合のみ
有効になります。

@param klass 拡張する対象のクラスまたはモジュールを指定します...
...ックで指定した機能を持つ無名のモジュールを返します。


//emlist[例][ruby]{
class C
def foo
puts "C#foo"
end
end

module
M
refine C do
def foo
puts "C#foo in M"
end
end
end

x = C.new
x.foo # => "C#foo"

using M

x = C.new
x.foo # => "C#foo in M"
/...

Module#remove_class_variable(name) -> object (1.0)

引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。

...ールやクラスに定義されていない場合に発生します。

//emlist[例][ruby]{
class Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}

@see Module#remove_const, Object#remove_instance_variable...

絞り込み条件を変える

Module#remove_const(name) -> object (1.0)

name で指定した定数を取り除き、その定数に設定されていた値を 返します。

...指定した(まだロードしてない)定数を含めて削除する事ができます。

取り除かれた定数は参照できなくなりますが、消える訳ではないので注意して
使用してください。

@see Module#remove_class_variable, Object#remove_instance_variable...

Module#remove_method(*name) -> self (1.0)

インスタンスメソッド name をモジュールから削除します。

...ring か Symbol を指定します。

@raise NameError 指定したメソッドが定義されていない場合に発生します。

//emlist[例][ruby]{
class C
def foo
end

remove_method :foo
remove_method :no_such_method # 例外 NameError が発生
end
//}

@see Module#undef_method...

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

...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#singleton_class? -> bool (1.0)

self が特異クラスの場合に true を返します。そうでなければ false を返し ます。

self が特異クラスの場合に true を返します。そうでなければ false を返し
ます。

//emlist[例][ruby]{
class C
end
C.singleton_class? # => false
C.singleton_class.singleton_class? # => true
//}

Module#to_s -> String (1.0)

モジュールやクラスの名前を文字列で返します。

...t[例][ruby]{
module
A
module
B
end

p B.name #=> "A::B"

class C
end
end

p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"

# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b0...

絞り込み条件を変える

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

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

...ng または Symbol で与えられることです。

//emlist[例][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.insta...
<< < ... 7 8 9 10 > >>