るりまサーチ

最速Rubyリファレンスマニュアル検索!
1283件ヒット [1-100件を表示] (0.031秒)
トップページ > クラス:Module[x]

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Module#<(other) -> bool | nil (1.0)

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

...ュールやクラス

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

```ruby title="例"
module
Flyable
end
class Bird
include Flyable
end
class Eagle < Bird
end
class Fish
end
p Bird < Flyable # => true
p Eagle < Bird # =>...
...true
p Eagle < Flyable # => true
p Eagle < Fish # => nil
p Eagle > Fish # => nil
Flyable < Object.new # => in `<': compared with non class/module (TypeError)
```...
...true
p Eagle < Flyable # => true
p Eagle < Fish # => nil
p Eagle > Fish # => nil
Flyable < Object.new # => in '<': compared with non class/module (TypeError)
```...

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

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

...ypeError` -- other がクラスやモジュールではない場合に発生します。

- **SEE** [m:Module#<]

```ruby title="例"
module
Awesome; end
module
Included
include Awesome
end
module
Prepended
prepend Awesome
end

p Included.ancestors # => [Included, Awesome]
p Awesome <= Included...

Module#<=>(other) -> -1 | 0 | 1 | nil (1.0)

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

...スやモジュールでなければ
nil を返します。

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

```ruby title="例"
module
Flyable
end
class Bird
include Flyable
end
class Eagle < Bird
end
class Fish
end
p Bird <=> Flyable # => -1
p Eagle <=> Bird # => -...

Module#===(obj) -> bool (1.0)

指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。 また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも真を返します。上記のいずれでもない場合に false を返します。

指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。
また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも真を返します。上記のいずれでもない場合に false を返します。

言い替えると obj.kind_of?(self) が true の場合、 true を返します。

このメソッドは主に case 文での比較に用いられます。
case ではクラス、モジュールの所属関係をチェックすることになります。

```ruby title="例"
str = String.new
case str
when Stri...

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

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

...ypeError` -- other がクラスやモジュールではない場合に発生します。

- **SEE** [m:Module#<]

```ruby title="例"
module
Awesome; end
module
Included
include Awesome
end
module
Prepended
prepend Awesome
end

p Included.ancestors # => [Included, Awesome]
p Awesome > Included #...

絞り込み条件を変える

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

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

...ypeError` -- other がクラスやモジュールではない場合に発生します。

- **SEE** [m:Module#<]

```ruby title="例"
module
Awesome; end
module
Included
include Awesome
end
module
Prepended
prepend Awesome
end

p Included.ancestors # => [Included, Awesome]
p Awesome >= Included...

Module#alias_method(new, original) -> Symbol (1.0)

メソッドの別名を定義します。

...メソッドの別名を定義します。

```ruby title="例"
module
Kernel
p alias_method :hoge, :puts # => :hoge
p alias_method "foo", :puts # => :foo
end
```

alias との違いは以下の通りです。

- メソッド名は [c:String] または [c:Symbol] で指定します
- グロ...
...のメソッド名。[c:String] または [c:Symbol] で指定します。

- **return** -- 作成したエイリアスのメソッド名を表す [c:Symbol] を返します。

- **SEE** [ref:d:spec/def#alias]

```ruby title="例"
module
Kernel
alias_method :foo, :puts
end

foo "bar" # bar
```...

Module#ancestors -> [Class, Module] (1.0)

クラス、モジュールのスーパークラスとインクルードしているモジュールを優先順位順に配列に格納して返します。

...す。

```ruby title="例"
module
Drivable
end
class Vehicle
include Drivable
end
class Car < Vehicle
p ancestors
p included_modules
p superclass
end
# => [Car, Vehicle, Drivable, Object, Kernel, BasicObject]
# => [Drivable, Kernel]
# => Vehicle
```

- **SEE** [m:Module#included_modules]...
<< 1 2 3 ... > >>