るりまサーチ

最速Rubyリファレンスマニュアル検索!
55件ヒット [1-55件を表示] (0.055秒)
トップページ > クエリ:d[x] > クエリ:path=[x] > クラス:Pathname[x]

別のキーワード

  1. bigdecimal/util to_d
  2. float to_d
  3. rsa d=
  4. rsa d
  5. matrix d

ライブラリ

キーワード

検索結果

Pathname#realdirpath(basedir = nil) -> Pathname (6213.0)

Pathname#realpath とほぼ同じで、最後のコンポーネントは実際に 存在しなくてもエラーになりません。

...
Pathname
#realpath とほぼ同じで、最後のコンポーネントは実際に
存在しなくてもエラーになりません。

@param basedir ベースディレクトリを指定します。省略するとカレントディレクトリになります。

//emlist[例][ruby]{
require "pathna...
...me"

path =
Pathname("/not_exist")
path.realdirpath # => #<Pathname:/not_exist>
path.realpath # => Errno::ENOENT

# 最後ではないコンポーネント(/not_exist_1)も存在しないのでエラーになる。
path =
Pathname("/not_exist_1/not_exist_2")
path.realdirpath # => Errno::ENOENT...
...//}

@see Pathname#realpath...

Pathname#expand_path(default_dir = &#39;.&#39;) -> Pathname (6107.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.expand_path("../") # => #<Pathname:/path/testfile>
//}

@see File.expand_path...

Pathname#cleanpath(consider_symlink = false) -> Pathname (113.0)

余計な "."、".." や "/" を取り除いた新しい Pathname オブジェクトを返します。

...計な "."、".." や "/" を取り除いた新しい Pathname オブジェクトを返します。

cleanpath は、実際にファイルシステムを参照することなく、文字列操作
だけで処理を行います。

@param consider_symlink 真ならパス要素にシンボリックリ...
...pathname"
path =
Pathname.new("//.././../")
path # => #<Pathname://.././../>
path.cleanpath # => #<Pathname:/>


require 'pathname'
D
ir.rmdir("/tmp/foo") rescue nil
File.unlink("/tmp/bar/foo") rescue nil
D
ir.rmdir("/tmp/bar") rescue nil
D
ir.mkdir("/tmp/foo")
D
ir.mkd...
...ir("/tmp/bar")
File.symlink("../foo", "/tmp/bar/foo")
path =
Pathname.new("bar/././//foo/../bar")
D
ir.chdir("/tmp")

path.cleanpath # => #<Pathname:bar/bar>
path.cleanpath(true) # => #<Pathname:bar/foo/../bar>
//}...

Pathname#realpath(basedir = nil) -> Pathname (107.0)

余計な "."、".." や "/" を取り除いた新しい Pathname オブジェクトを返します。

...余計な "."、".." や "/" を取り除いた新しい Pathname オブジェクトを返します。

また、ファイルシステムをアクセスし、実際に存在するパスを返します。
シンボリックリンクも解決されます。

self が指すパスが存在しない場...
...sedir ベースディレクトリを指定します。省略するとカレントディレクトリになります。

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

D
ir.rmdir("/tmp/foo") rescue nil
File.unlink("/tmp/bar/foo") rescue nil
D
ir.rmdir("/tmp/bar") rescue nil

D
ir.mkdir("/tmp/foo")
D
i...
...r.mkdir("/tmp/bar")
File.symlink("../foo", "/tmp/bar/foo")
path =
Pathname.new("bar/././//foo/../bar")

D
ir.chdir("/tmp")

p path.realpath

# => ruby 1.8.0 (2003-10-10) [i586-linux]
# #<Pathname:/tmp/bar>
//}

@see Pathname#realdirpath, File.realpath...

Pathname#relative_path_from(base_directory) -> Pathname (107.0)

base_directory から self への相対パスを求め、その内容の新しい Pathname オブジェクトを生成して返します。

...base_directory から self への相対パスを求め、その内容の新しい Pathname
オブジェクトを生成して返します。

パス名の解決は文字列操作によって行われ、ファイルシステムをアクセス
しません。

self が相対パスなら base_directory...
...elf が絶対パスなら
base_directory も絶対パスでなければなりません。

@param base_directory ベースディレクトリを表す Pathname オブジェクトを指定します。

@raise ArgumentError Windows上でドライブが違うなど、base_directory から self への相...
...対パスが求められないときに例外が発生します。

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

path =
Pathname.new("/tmp/foo")
base = Pathname.new("/tmp")

path.relative_path_from(base) # => #<Pathname:foo>
//}...

絞り込み条件を変える