るりまサーチ

最速Rubyリファレンスマニュアル検索!
987件ヒット [101-200件を表示] (0.111秒)

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. zlib end

検索結果

<< < 1 2 3 4 ... > >>

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

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

...のみ返します。

@see 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.pub...
...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; def public_foo() end
end


# あるクラ...

Module#method_defined?(name, inherit=true) -> bool (50.0)

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

...す。

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

//emlist[例][ruby]{
module
A
def method1() end
def protected_method1() end
protected :protected_method1
end

class B
def method2() end
def private_method2() end
private :priv...
...ate_method2
end
class C < B
include A
def method3() end
end


A.method_defined? :method1 #=> true
C.method_defined? "method1" #=> true
C.method_defined? "method2" #=> true
C.method_defined? "method2", true #=> true
C.method_defined? "method2", false...

Module#include(*mod) -> self (44.0)

モジュール mod をインクルードします。

...@param mod Module のインスタンス( Enumerable など)を指定します。

@raise ArgumentError 継承関係が循環してしまうような include を行った場合に発生します。

//emlist[例][ruby]{
module
M
end

module
M2
include M
end

module
M
include M2
end

//}

実行結...
...果:

-:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from -:3


インクルードとは、指定されたモジュールの定義
(メソッド、定数) を引き継ぐことです。
インクルードは多重継承の代わりに用...
...いられており、 mix-in とも呼びます。

//emlist[例][ruby]{
class C
include FileTest
include Math
end


p C.ancestors

# => [C, Math, FileTest, Object, Kernel]
//}

モジュールの機能追加は、クラスの継承関係の間にそのモジュールが挿入
されることで...

Module#instance_method(name) -> UnboundMethod (38.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...した場合に発生します。

@see 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_me...
...d(: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#private_instance_methods(inherited_too = true) -> [Symbol] (38.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_insta...

絞り込み条件を変える

Module#private_method_defined?(name, inherit=true) -> bool (38.0)

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

...対象になります。

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

//emlist[例][ruby]{
module
A
def method1() end
end

class B
private
def method2() end
end

class C < B
include A
def method3() end
end


A.method_defined? :method1...

Module#protected_method_defined?(name, inherit=true) -> bool (38.0)

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

...対象になります。

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

//emlist[例][ruby]{
module
A
def method1() end
end

class B
protected
def method2() end
end

class C < B
include A
def method3() end
end


A.method_defined? :method1...

Module#public_method_defined?(name, inherit=true) -> bool (38.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
include A
def method3() end
end


A.method_defined? :method1...

Module#refine(klass) { ... } -> Module (32.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 拡張する対象のクラスまたはモジュールを指定します...
...機能を持つ無名のモジュールを返します。

//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"
//}

@see main.using...
<< < 1 2 3 4 ... > >>