るりまサーチ

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

別のキーワード

  1. etc sc_xopen_enh_i18n
  2. rsa n
  3. rsa n=
  4. openssl n
  5. openssl n=

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

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

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

...を処理するため、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 の組み合わせの例
module X
def foo
puts "X1" # (1x)
super # (2x)
puts "X2" # (3x)
end
end

class A
prepend
X

def foo
puts "A" #(1a)
end
end

A.new.foo
# (1x) (2x)(こ...

String#prepend(*arguments) -> String (24216.0)

複数の文字列を先頭に破壊的に追加します。

...複数の文字列を先頭に破壊的に追加します。

@param arguments 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "!!!"
a.prepend # => "!!!"
a # => "!!!"

a = "!!!"
a.prepend "hello ", "world" # => "hello world!!!"
a # => "hello...

String#prepend(other_str) -> String (24211.0)

文字列 other_str を先頭に破壊的に追加します。

...文字列 other_str を先頭に破壊的に追加します。

@param other_str 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "world"
a.prepend("hello ") # => "hello world"
a # => "hello world"
//}...

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

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

...追加したいオブジェクトを指定します。

//emlist[例][ruby]{
arr = [1,2,3]
arr.unshift 0
p arr #=> [0, 1, 2, 3]
arr.unshift [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#sh...

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

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

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

このメソッドを上書きすることで、prepend の処理を変...
...aram 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

Reco...
...rder::RECORDS # => [A, C]
//}

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

絞り込み条件を変える

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

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

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

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

//emlist[例][ruby]{
module A
def self.prepended(mod)
p...
...uts "#{self} prepended to #{mod}"
end
end
module Enumerable
prepend
A
end
# => "A prepended to Enumerable"
//}

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

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

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

...追加したいオブジェクトを指定します。

//emlist[例][ruby]{
arr = [1,2,3]
arr.unshift 0
p arr #=> [0, 1, 2, 3]
arr.unshift [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#sh...

Object#kind_of?(mod) -> bool (3107.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...ルードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prepend
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に...
...です。

//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end

obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

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

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

...
n
il を返します。

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

@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

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

Bar.ancest...
...ors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true

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

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

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

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

...
n
il を返します。

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

@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Awesome; end
module Included
include Awesome
end
module Prepended
prepend
Awe...
...some
end

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

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

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

絞り込み条件を変える

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

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

...
n
il を返します。

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

@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

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

Bar.ancest...
...ors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false

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

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