るりまサーチ

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

別のキーワード

  1. _builtin path
  2. pathname to_path
  3. _builtin absolute_path
  4. _builtin to_path
  5. pstore path

ライブラリ

モジュール

キーワード

検索結果

<< 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 (32000.0)

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

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

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

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

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

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

@param consider_symlink 真ならパス要素にシンボリック...
...題ないように .. を残します。

//emlist[例][ruby]{
require "pathname"
path
= Pathname.new("//.././../")
path
# => #<Pathname://.././../>
path
.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")
path
= Pathname.new("bar/././//foo/../bar")
Dir.chdir("/tmp")

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

Pathname#realdirpath(basedir = nil) -> Pathname (30377.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#relative_path_from(base_directory) -> Pathname (30366.0)

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

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

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

self が相対パスなら base_directory...
...リを表す Pathname オブジェクトを指定します。

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

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

path
= Pathname.new("/tmp/fo...
...o")
base = Pathname.new("/tmp")

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

Pathname#realpath -> Pathname (30354.0)

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

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

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

self が指すパスが存在しない場...
...uire '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")
path
= 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 (30354.0)

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

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

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

self が指すパスが存在しない場...
...uire '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")
path
= 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#to_path -> String (30123.0)

File.open などの引数に渡す際に呼ばれるメソッドです。 Pathname オブジェ クトにおいては、 to_s と同じです。

...File.open などの引数に渡す際に呼ばれるメソッドです。 Pathname オブジェ
クトにおいては、 to_s と同じです。


@see Pathname#to_s...

Pathname::TO_PATH -> Symbol (30101.0)

内部的に使っている定数です。利用者が使うことはありません。

内部的に使っている定数です。利用者が使うことはありません。

絞り込み条件を変える

<< 1 2 3 ... > >>