るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

検索結果

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

Module#undef_method(*name) -> self (86.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 の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end

B.new.ok #...
...class 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 #=>...
...["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 #=> []
//}...

Module#instance_methods(inherited_too = true) -> [Symbol] (68.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_...
...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#include(*mod) -> self (62.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#method_defined?(name, inherit=true) -> bool (56.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#instance_method(name) -> UnboundMethod (44.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] (44.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 (44.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 (44.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 (44.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...
<< < 1 2 3 4 ... > >>