種類
- インスタンスメソッド (1214)
- 特異メソッド (69)
キーワード
- < (13)
- <= (13)
- <=> (13)
- === (13)
- > (13)
- >= (13)
-
alias
_ method (13) - ancestors (13)
-
append
_ features (13) - attr (39)
-
attr
_ accessor (13) -
attr
_ reader (13) -
attr
_ writer (13) - autoload (13)
- autoload? (13)
-
class
_ eval (26) -
class
_ exec (13) -
class
_ variable _ defined? (13) -
class
_ variable _ get (13) -
class
_ variable _ set (13) -
class
_ variables (13) -
const
_ added (4) -
const
_ defined? (13) -
const
_ get (13) -
const
_ missing (13) -
const
_ set (13) -
const
_ source _ location (13) - constants (26)
-
define
_ method (26) -
deprecate
_ constant (13) -
extend
_ object (13) - extended (13)
- freeze (13)
- include (13)
- include? (13)
- included (13)
-
included
_ modules (13) - inspect (13)
-
instance
_ method (13) -
instance
_ methods (13) -
method
_ added (13) -
method
_ defined? (13) -
method
_ removed (13) -
method
_ undefined (13) -
module
_ eval (26) -
module
_ exec (13) -
module
_ function (39) - name (13)
- nesting (13)
- new (26)
- prepend (13)
-
prepend
_ features (13) - prepended (13)
- private (52)
-
private
_ class _ method (26) -
private
_ constant (13) -
private
_ instance _ methods (13) -
private
_ method _ defined? (13) - protected (52)
-
protected
_ instance _ methods (13) -
protected
_ method _ defined? (13) - public (52)
-
public
_ class _ method (26) -
public
_ constant (13) -
public
_ instance _ method (13) -
public
_ instance _ methods (13) -
public
_ method _ defined? (13) -
rake
_ extension (13) - refine (13)
- refinements (4)
-
remove
_ class _ variable (13) -
remove
_ const (13) -
remove
_ method (13) -
ruby2
_ keywords (13) -
set
_ temporary _ name (6) -
singleton
_ class? (13) -
to
_ s (13) -
undef
_ method (13) -
undefined
_ instance _ methods (4) -
used
_ modules (13) -
used
_ refinements (4) - using (13)
検索結果
先頭5件
-
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]...
