るりまサーチ

最速Rubyリファレンスマニュアル検索!
516件ヒット [1-100件を表示] (0.138秒)
トップページ > 種類:インスタンスメソッド[x] > クエリ:p[x] > クエリ:d[x] > クラス:Pathname[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Pathname#expand_path(default_dir = &#39;.&#39;) -> Pathname (21402.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#realdirpath(basedir = nil) -> Pathname (15402.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...

Pathname#opendir -> Dir (12302.0)

Dir.open(self.to_s, &block) と同じです。

...Dir.open(self.to_s, &block) と同じです。


@see Dir.open...

Pathname#opendir {|dir| ... } -> nil (12302.0)

Dir.open(self.to_s, &block) と同じです。

...Dir.open(self.to_s, &block) と同じです。


@see Dir.open...

Pathname#grpowned? -> bool (12202.0)

FileTest.grpowned?(self.to_s) と同じです。

...FileTest.grpowned?(self.to_s) と同じです。


@see FileTest.#grpowned?...

絞り込み条件を変える

Pathname#each_child(with_directory = true) {|pathname| ...} -> [Pathname] (9314.0)

self.children(with_directory).each と同じです。

....children(with_directory).each と同じです。

@param with_directory 偽を指定するとファイル名のみ返します。デフォルトは真です。

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

Pathname
("/usr/local").each_child {|f| p f }
# => #<Pathname:/usr/local/bin>
# => #<Pathname:/usr...
...#<Pathname:/usr/local/include>
# => #<Pathname:/usr/local/lib>
# => #<Pathname:/usr/local/opt>
# => #<Pathname:/usr/local/sbin>
# => #<Pathname:/usr/local/share>
# => #<Pathname:/usr/local/var>

Pathname
("/usr/local").each_child(false) {|f| p f }
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pat...
...hname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
# => #<Pathname:sbin>
# => #<Pathname:share>
# => #<Pathname:var>
//}

@see Pathname#children...

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

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

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

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

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

@para...
...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")
p
ath = 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#cleanpath(consider_symlink = false) -> Pathname (9302.0)

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

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

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

@param consider_symlink 真ならパス要素にシンボリックリ...
...pathname"
p
ath = Pathname.new("//.././../")
p
ath # => #<Pathname://.././../>
p
ath.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")
p
ath = Pathname.new("bar/././//foo/../bar")
D
ir.chdir("/tmp")

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

Pathname#relative_path_from(base_directory) -> Pathname (9302.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'

p
ath = Pathname.new("/tmp/foo")
base = Pathname.new("/tmp")

p
ath.relative_path_from(base) # => #<Pathname:foo>
//}...
<< 1 2 3 ... > >>