るりまサーチ

最速Rubyリファレンスマニュアル検索!
696件ヒット [501-600件を表示] (0.050秒)

別のキーワード

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

検索結果

<< < ... 4 5 6 7 > >>

Module#prepend(*modules) -> self (26.0)

指定したモジュールを self の継承チェインの先頭に「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。

...追加されるため、結果として self で定義されたメソッドは
override されます。

module
s で指定したモジュールは後ろから順に処理されるため、
module
s の先頭が最も優先されます。

また、継承によってこの「上書き」を処理す...
...のモジュール/クラスのメソッドを呼び出すことができます。

実際の処理は modules の各要素の prepend_features を後ろから順に呼びだすだけです。
Module
#prepend_features が継承チェインの改変を実行し、結果として上のような
処理...
...きます。


@param modules prepend する Module を指定します
@see Module#prepend_features, Module#prepended

//emlist[例][ruby]{
# super と prepend の組み合わせの例
module
X
def foo
puts "X1" # (1x)
super # (2x)
puts "X2" # (3x)
end
end

class
A
prepend X

def...

Module#private_constant(*name) -> self (26.0)

name で指定した定数の可視性を private に変更します。

...数を指定した場合に発生します。

@return self を返します。

@see Module#public_constant, Object#untrusted?

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
class
Baz; end
QUX = 'qux'
class
Quux; end

private_constant :QUX
private_constant :Quux
end

Foo::BAR # => "bar"
F...
...しない定数を指定した場合に発生します。

@return self を返します。

@see Module#public_constant

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
class
Baz; end
QUX = 'qux'
class
Quux; end

private_constant :QUX
private_constant :Quux
end

Foo::BAR # => "bar"
Foo::Baz...

Module#private_method_defined?(name, inherit=true) -> bool (26.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...

Module#protected_method_defined?(name, inherit=true) -> bool (26.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...

Module#public_method_defined?(name, inherit=true) -> bool (26.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...

絞り込み条件を変える

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

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

...meError 引数で指定された定数がそのモジュールやクラスに定義されていない場合に発生します。

//emlist[例][ruby]{
class
Foo
FOO = 1
p remove_const(:FOO) # => 1
p FOO # => uninitialized constant FOO at Foo (NameError)
end
//}

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

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

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

Module#define_method(name) { ... } -> Symbol (20.0)

インスタンスメソッド name を定義します。

...

@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class
Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...

Module#define_method(name, method) -> Symbol (20.0)

インスタンスメソッド name を定義します。

...

@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class
Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...

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

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

...します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@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"; en...
<< < ... 4 5 6 7 > >>