るりまサーチ (Ruby 3.4)

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

別のキーワード

  1. pathname expand_path
  2. rbconfig expand
  3. file expand_path
  4. _builtin expand_path
  5. text expand_tabs

ライブラリ

クラス

モジュール

検索結果

Pathname#expand_path(default_dir = '.') -> Pathname (54424.0)

Pathname.new(File.expand_path(self.to_s, *args)) と同じです。

Pathname.new(File.expand_path(self.to_s, *args)) と同じです。

@param default_dir self が相対パスであれば default_dir を基準に展開されます。

//emlist[例][ruby]{
require "pathname"

path = Pathname("testfile")
Pathname.pwd # => #<Pathname:/path/to>
path.expand_path # => #<Pathname:/path/to/testfile>
path.e...

File.expand_path(path, default_dir = &#39;.&#39;) -> String (54412.0)

path を絶対パスに展開した文字列を返します。 path が相対パスであれば default_dir を基準にします。

path を絶対パスに展開した文字列を返します。
path が相対パスであれば default_dir を基準にします。

先頭の ~ はホームディレクトリ(環境変数 HOME が使われます)に、
~USER はそのユーザのホームディレクトリに展開されます。

//emlist[例][ruby]{
p Dir.getwd #=> "/home/matz/work/foo"
p ENV["HOME"] #=> "/home/matz"
p File.expand_path("..") #=> "/h...

Kernel.#require_relative(relative_feature) -> bool (37.0)

現在のファイルからの相対パスで require します。

現在のファイルからの相対パスで require します。

require File.expand_path(relative_feature, File.dirname(__FILE__))
とほぼ同じです。

Kernel.#eval などで文字列を評価した場合に、そこから
require_relative を呼出すと必ず失敗します。

@param relative_feature ファイル名の文字列です。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require

=== require と load のスコープ

ローカル変数...