るりまサーチ (Ruby 3.0)

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

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub!

ライブラリ

クラス

検索結果

Dir.home(user) -> String | nil (55006.0)

現在のユーザまたは指定されたユーザのホームディレクトリを返します。

現在のユーザまたは指定されたユーザのホームディレクトリを返します。

Dir.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。

//emlist[例][ruby]{
Dir.home # => "/home/vagrant"
Dir.home("root") # => "/root"
//}

@see File.expand_path

Dir.home -> String | nil (54706.0)

現在のユーザまたは指定されたユーザのホームディレクトリを返します。

現在のユーザまたは指定されたユーザのホームディレクトリを返します。

Dir.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。

//emlist[例][ruby]{
Dir.home # => "/home/vagrant"
Dir.home("root") # => "/root"
//}

@see File.expand_path

File.expand_path(path, default_dir = '.') -> String (448.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...