るりまサーチ

最速Rubyリファレンスマニュアル検索!
963件ヒット [1-100件を表示] (0.106秒)

別のキーワード

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

検索結果

<< 1 2 3 ... > >>

Module#>(other) -> bool | nil (18162.0)

比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。

...ee Module#<

//emlist[例][ruby]{
module
Awesome; end
module
Included
include Awesome
end

module
Prepended
prepend Awesome
end


Included.ancestors # => [Included, Awesome]
Awesome > Included # => true
Included > Awesome # => false

Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepende...
...d # => true
Prepended > Awesome # => false

Awesome > Awesome # => false
Awesome > Object # => nil
//}...

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

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

...たメソッドは
override されます。

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

また、継承によってこの「上書き」を処理するため、prependの引数として
渡したモジュール...
...理は modules の各要素の prepend_features を後ろから順に呼びだすだけです。
Module
#prepend_features が継承チェインの改変を実行し、結果として上のような
処理が実現されます。そのため、prepend_features を override することで
prepend...
...す。


@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 foo...

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

...r
method, and only for backwards compatibility with Ruby versions before
2.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, b...
...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(:"do_#{meth}", *args, &block)
end

ruby
2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
end

//}...

Module#prepend_features(mod) -> self (6244.0)

Module#prepend から呼び出されるメソッドで、 prepend の処理の実体です。このメソッド自体は mod で指定した モジュール/クラスの継承チェインの先頭に self を追加します。

...Module#prepend から呼び出されるメソッドで、
prepend の処理の実体です。このメソッド自体は mod で指定した
モジュール/クラスの継承チェインの先頭に self を追加します。

このメソッドを上書きすることで、prepend の処理を変...
...m mod prepend を呼び出したモジュール
@return mod が返されます

//emlist[例][ruby]{
class Recorder
RECORDS = []
end


module
X
def self.prepend_features(mod)
Recorder::RECORDS << mod
end

end


class A
prepend X
end


class B
include X
end


class C
prepend X
end


Recorde...
...r::RECORDS # => [A, C]
//}

@see Module#prepend, Module#prepended...

Module#append_features(module_or_class) -> self (6226.0)

モジュール(あるいはクラス)に self の機能を追加します。

...ドは Module#include の実体であり、
include を Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def include(*modules)
module
s.reverse_each do |mod|
# append_features や included はプライベートメソッドなので
# 直接 mod.append_features(...
...self) などとは書けない
mod.__send__(:append_features, self)
mod.__send__(:included, self)
end

end

//}

@see Module#included...

絞り込み条件を変える

Module#extend_object(obj) -> object (6226.0)

Object#extend の実体です。オブジェクトにモジュールの機能を追加します。

...Object#extend の実体です。オブジェクトにモジュールの機能を追加します。

Object#extend は、Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def extend(*modules)
module
s.reverse_each do |mod|
# extend_object や extended はプライ...
...ベートメソッドなので
# 直接 mod.extend_object(self) などとは書けない
mod.__send__(:extend_object, self)
mod.__send__(:extended, self)
end

end

//}

extend_object のデフォルトの実装では、self に定義されて
いるインスタンスメソッドを obj...
...の特異メソッドとして追加します。

@param obj self の機能を追加するオブジェクトを指定します。

@return obj で指定されたオブジェクトを返します。

@see Module#extended...

Module#extended(obj) -> () (6226.0)

self が他のオブジェクト に Object#extend されたときに 呼ばれます。引数には extend を行ったオブジェクトが渡されます。

...xtend されたときに
呼ばれます。引数には extend を行ったオブジェクトが渡されます。

@param obj Object#extend を行ったオブジェクト

//emlist[例][ruby]{
module
Foo
def self.extended(obj)
p "#{obj} extend #{self}"
end

end


Object.new.extend Foo

# => "...
...#<Object:0x401cbc3c> extend Foo"
//}

@see Module#extend_object...

Module#prepended(class_or_module) -> () (6226.0)

self が Module#prepend されたときに対象のクラスまたはモジュールを 引数にしてインタプリタがこのメソッドを呼び出します。

...self が Module#prepend されたときに対象のクラスまたはモジュールを
引数にしてインタプリタがこのメソッドを呼び出します。

@param class_or_module Module#prepend を実行したオブジェクト

//emlist[例][ruby]{
module
A
def self.prepended(mod)...
...puts "#{self} prepended to #{mod}"
end

end

module
Enumerable
prepend A
end

# => "A prepended to Enumerable"
//}

@see Module#included, Module#prepend, Module#prepend_features...

Module#<=>(other) -> Integer | nil (6132.0)

self と other の継承関係を比較します。

...のクラスやモジュール

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

class Bar
include Foo
end

class Baz < Bar
end

class Qux
end

p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...
<< 1 2 3 ... > >>