るりまサーチ

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

別のキーワード

  1. argf.class each_line
  2. argf.class each
  3. argf.class lines
  4. argf.class set_encoding
  5. argf.class to_a

ライブラリ

クラス

検索結果

Method#source_location -> [String, Integer] | nil (24339.0)

ソースコードのファイル名と行番号を配列で返します。

...列で返します。

その手続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。

@see Proc#source_location

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class
Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----...
...require '/tmp/foo'

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.source_location # => ["/tmp/foo.rb", 2]

method(:puts).source_location # => nil
//}...

Module#const_source_location(name, inherited = true) -> [String, Integer] (18505.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義され...
...//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 # 定数を再定義する
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('C3', false) # => nil -- include したモジュールは検索しない

p A.const_source_location('C2') # => ["test...