るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
8件ヒット [1-8件を表示] (0.037秒)
トップページ > バージョン:2.1.0[x] > クエリ:h[x] > クエリ:dir[x] > クエリ:getwd[x]

別のキーワード

  1. _builtin to_h
  2. hash to_h
  3. env to_h
  4. array to_h
  5. ostruct to_h

ライブラリ

クラス

キーワード

検索結果

Pathname.getwd -> Pathname (63754.0)

カレントディレクトリを元に Pathname オブジェクトを生成します。 Pathname.new(Dir.getwd) と同じです。

カレントディレクトリを元に Pathname オブジェクトを生成します。
Pathname.new(Dir.getwd) と同じです。

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

Pathname.getwd #=> #<Pathname:/home/zzak/projects/ruby>
//}

@see Dir.getwd

Shell#dir -> String (54307.0)

カレントディレクトリのパスを文字列で返します。

カレントディレクトリのパスを文字列で返します。

使用例
require 'shell'
sh = Shell.new
p sh.cwd
# 例
#=> "/Users/kouya/tall"

Shell#getwd -> String (54307.0)

カレントディレクトリのパスを文字列で返します。

カレントディレクトリのパスを文字列で返します。

使用例
require 'shell'
sh = Shell.new
p sh.cwd
# 例
#=> "/Users/kouya/tall"

File.expand_path(path, default_dir = &#39;.&#39;) -> String (18724.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...

File.absolute_path(file_name, dir_string=nil) -> String (18658.0)

file_name を絶対パスに変換した文字列を返します。

file_name を絶対パスに変換した文字列を返します。

相対パスの場合はカレントディレクトリを基準とします。
dir_string を渡した場合はそのディレクトリを基準とします。

File.expand_path と異なり、 file_name 先頭が "~" である場合
それは展開されません。普通のディレクトリ名として処理されます。

//emlist[例][ruby]{
p Dir.getwd #=> "/home/matz/work/bar"
p ENV["HOME"] #=> "/home/mat...

絞り込み条件を変える

Pathname.pwd -> Pathname (18454.0)

カレントディレクトリを元に Pathname オブジェクトを生成します。 Pathname.new(Dir.getwd) と同じです。

カレントディレクトリを元に Pathname オブジェクトを生成します。
Pathname.new(Dir.getwd) と同じです。

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

Pathname.getwd #=> #<Pathname:/home/zzak/projects/ruby>
//}

@see Dir.getwd

Shell#cwd -> String (9007.0)

カレントディレクトリのパスを文字列で返します。

カレントディレクトリのパスを文字列で返します。

使用例
require 'shell'
sh = Shell.new
p sh.cwd
# 例
#=> "/Users/kouya/tall"

Shell#pwd -> String (9007.0)

カレントディレクトリのパスを文字列で返します。

カレントディレクトリのパスを文字列で返します。

使用例
require 'shell'
sh = Shell.new
p sh.cwd
# 例
#=> "/Users/kouya/tall"