5件ヒット
[1-5件を表示]
(0.430秒)
検索結果
-
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (24375.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...号を配列で返します。
@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりませ......nil を返します。
定数は見つかったがソースファイルが見つからなかった場合は空の配列を返します。
//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
includ......class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end
p B.const_source_location('C4') # => ["test.rb", 12]
p B.const_source_location('C3') # => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]
p B.const_source_location('C...