Ruby 2.4.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > LoadErrorクラス > path

instance method LoadError#path

path -> String | nil[permalink][rdoc]

Kernel.#requireKernel.#load に失敗したパスを返します。

begin
  require 'this/file/does/not/exist'
rescue LoadError => e
  e.path # => 'this/file/does/not/exist'
end

パスが定まらない場合は nil を返します。