るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

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

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

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

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

また、継承によってこの「上書き」を処理するため、prependの引数として
渡したモジ...
...スタンスメソッドでsuperを呼ぶことで
self のモジュール/クラスのメソッドを呼び出すことができます。

実際の処理は modules の各要素の prepend_features を後ろから順に呼びだすだけです。
Module#prepend_features が継承チェインの改...
...されます。そのため、prepend_features を override することで
prepend
の処理を追加/変更できます。


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

//emlist[例][ruby]{
# super prepend の組み合わせの例
mod...

Array#prepend(*obj) -> self (24314.0)

指定された obj を引数の最後から順番に配列の先頭に挿入します。 引数を指定しなければ何もしません。

...た obj を引数の最後から順番に配列の先頭に挿入します。
引数を指定しなければ何もしません。

@param obj 自身に追加したいオブジェクトを指定します。

//emlist[例][ruby]{
arr = [1,2,3]
arr.unshift 0
p arr #=> [0, 1, 2, 3]
arr.unshi...
...ft [0]
p arr #=> [[0], 0, 1, 2, 3]
arr.unshift 1, 2
p arr #=> [1, 2, [0], 0, 1, 2, 3]
//}

@see Array#push, Array#pop, Array#shift...

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

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

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

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

//emlist[例][ruby]{
class Recorder
R
ECORDS = []
end

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

class A
prepend
X
end

class B
include X
end

class C
prepend
X
end

R
ecor...
...der::RECORDS # => [A, C]
//}

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

Array#unshift(*obj) -> self (6114.0)

指定された obj を引数の最後から順番に配列の先頭に挿入します。 引数を指定しなければ何もしません。

...た obj を引数の最後から順番に配列の先頭に挿入します。
引数を指定しなければ何もしません。

@param obj 自身に追加したいオブジェクトを指定します。

//emlist[例][ruby]{
arr = [1,2,3]
arr.unshift 0
p arr #=> [0, 1, 2, 3]
arr.unshi...
...ft [0]
p arr #=> [[0], 0, 1, 2, 3]
arr.unshift 1, 2
p arr #=> [1, 2, [0], 0, 1, 2, 3]
//}

@see Array#push, Array#pop, Array#shift...

Module#<=(other) -> bool | nil (219.0)

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

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

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジ...
...@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend
Foo
end

B
ar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
B
ar <= Foo # => true

B
az.ancestors # =>...
...[Foo, Baz]
Foo <= Baz # => false
B
az <= Foo # => true

Foo <= Foo # => true
Foo <= Object # => nil
//}...

絞り込み条件を変える

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

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

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

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジュールやクラス

@raise TypeError other...
...][ruby]{
module Awesome; end
module Included
include Awesome
end
module Prepended
prepend
Awesome
end

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

Prepend
ed.ancestors # => [Awesome, Prepended]
Awesome > Prepended # => true
Prepend
ed > A...
...wesome # => false

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

Module#>=(other) -> bool | nil (219.0)

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

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

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジュールやクラス

@raise TypeError other...
...ule#<

//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend
Foo
end

B
ar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
B
ar >= Foo # => false

B
az.ancestors # => [Foo, Baz]
Foo >= Baz # => true
B
az >= Foo # => false

Foo >= Foo # => true
Foo >= Object # => nil
//}...