るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. matrix p
  5. dh p=

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Pathname (44078.0)

パス名をオブジェクト指向らしく扱うクラスです。

...クラスです。

Pathname
オブジェクトはパス名を表しており、ファイルやディレクトリそのものを表してはいません。
当然、存在しないファイルのパス名も扱えます。

絶対パスも相対パスも扱えます。

Pathname
オブジェクト...
...るメソッドはありません。

Pathname
のインスタンスメソッドには、ディレクトリのパスを返す Pathname#dirname のように、
文字列操作だけで結果を返すものもあれば、ファイルの中身を読み出す Pathname#read のように
ファイルシ...
...ムにアクセスするものもあります。

Pathname
オブジェクトの生成には、Pathname.new のほかに Kernel#Pathname も使えます。

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

Pathname
.new("foo/bar") # => #<Pathname:foo/bar>
Pathname
("foo/bar") # => #<Pathname:foo/bar>
//}...

Pathname#expand_path(default_dir = &#39;.&#39;) -> Pathname (36453.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"

p
ath = Pathname("testfile")
Pathname
.pwd # => #<Pathname:/path/to>
p
ath.expand_...
...path # => #<Pathname:/path/to/testfile>
p
ath.expand_path("../") # => #<Pathname:/path/testfile>
//}

@see File.expand_path...

Pathname::SEPARATOR_PAT -> Regexp (36200.0)

パス名のなかのディレクトリを区切る部分にマッチする正規表現です。

パス名のなかのディレクトリを区切る部分にマッチする正規表現です。

この値は環境依存です。

pathname (32000.0)

パス名をオブジェクト指向らしく扱うためのライブラリです。

パス名をオブジェクト指向らしく扱うためのライブラリです。

Pathname#parent -> Pathname (30371.0)

self の親ディレクトリを指す新しい Pathname オブジェクトを返します。

...新しい Pathname オブジェクトを返します。

//emlist[例 絶対パス][ruby]{
require "pathname"

p
ath = Pathname("/usr")
p
ath # => #<Pathname:/usr>
p
ath.parent # => #<Pathname:/>
//}

//emlist[例 相対パス][ruby]{
require "pathname"

p
ath = Pathname("foo/bar")
p
ath.parent...
...# => #<Pathname:foo>
p
ath.parent.parent # => #<Pathname:.>
p
ath.parent.parent.parent # => #<Pathname:..>
//}...

絞り込み条件を変える

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

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

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

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

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


require 'pathname'
Dir.rmdir("/tmp/foo") rescue nil
File.unlink("/tmp/bar/foo") rescue nil
Dir.rmdir("/tmp/bar") rescue nil
Dir.mkdir("/tmp/foo")...
...Dir.mkdir("/tmp/bar")
File.symlink("../foo", "/tmp/bar/foo")
p
ath = Pathname.new("bar/././//foo/../bar")
Dir.chdir("/tmp")

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

Pathname#realpath -> Pathname (30348.0)

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

... Pathname オブジェクトを返します。

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

self が指すパスが存在しない場合は例外 Errno::ENOENT が発生します。

@para...
...quire 'pathname'

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

Dir.mkdir("/tmp/foo")
Dir.mkdir("/tmp/bar")
File.symlink("../foo", "/tmp/bar/foo")
p
ath = Pathname.new("bar/././//foo/../bar")

Dir.chdir("/tmp")

p
path.realpath

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

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

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

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

... Pathname オブジェクトを返します。

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

self が指すパスが存在しない場合は例外 Errno::ENOENT が発生します。

@para...
...quire 'pathname'

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

Dir.mkdir("/tmp/foo")
Dir.mkdir("/tmp/bar")
File.symlink("../foo", "/tmp/bar/foo")
p
ath = Pathname.new("bar/././//foo/../bar")

Dir.chdir("/tmp")

p
path.realpath

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

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

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

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

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

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

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

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

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

@see Pathname#realpath...
<< 1 2 3 ... > >>