2件ヒット
[1-2件を表示]
(0.033秒)
ライブラリ
- ビルトイン (2)
キーワード
- <=> (1)
-
const
_ source _ location (1)
検索結果
先頭2件
-
Module
# <=>(other) -> Integer | nil (307.0) -
self と other の継承関係を比較します。
...がクラスやモジュールでなければ
nil を返します。
@param 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 # =>... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (307.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...が見つからなかった場合は空の配列を返します。
//emlist[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end
module M # line 6
C3 = 3
end
class B < A # line 10
include M
C4 = 4
end
class A # 継続して A を定義する
C2 = 8 # 定数を......] -- Object を継承している為
p M.const_source_location('A') # => ["test.rb", 1] -- Object は継承していないが追加で modules をチェックする
p Object.const_source_location('A::C1') # => ["test.rb", 2] -- ネストの指定もサポートしている
p Object....