るりまサーチ

最速Rubyリファレンスマニュアル検索!
38件ヒット [1-38件を表示] (0.051秒)
トップページ > クエリ:nil[x] > クエリ:at[x] > クエリ:source_location[x]

別のキーワード

  1. _builtin at
  2. _builtin values_at
  3. time at
  4. dbm values_at
  5. csv values_at

ライブラリ

クラス

検索結果

Proc#source_location -> [String, Integer] | nil (24344.0)

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

... nil を返します。


//emlist[例][ruby]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc {}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location #...
...=> nil
//}

@see Method#source_location...

UnboundMethod#source_location -> [String, Integer] | nil (24338.0)

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

... nil を返します。

//emlist[例][ruby]{
require 'time'

Time.instance_method(:zone).source_location # => nil
Time.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/ruby/2.4.0/time.rb", 654]
//}

@see Proc#source_location, Method#source_location...

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

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

...
である)場合は 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] (12279.0)

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

...ん。
@return ソースコードのファイル名と行番号を配列で返します。
指定した定数が見つからない場合は nil を返します。
定数は見つかったがソースファイルが見つからなかった場合は空の配列を返します。

//eml...
...を再定義する
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.rb", 16] -- 最後に定義された位置を返す

p Object.const_source_location('B') # => ["test.rb", 10] -- Object はトップレベルの定数を検索する
p Object.const_source_location('A') # => ["test.rb", 1] -...