るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

モジュール

検索結果

<< 1 2 3 ... > >>

Pathname#readable_real? -> bool (29300.0)

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

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


@see FileTest.#readable_real?...

Pathname#children(with_directory = true) -> [Pathname] (23447.0)

self 配下にあるパス名(Pathnameオブジェクト)の配列を返します。

...self 配下にあるパス名(Pathnameオブジェクト)の配列を返します。

ただし、 ".", ".." は要素に含まれません。

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

@raise Errno::EXXX self が存在しないパ...
...スであったりディレクトリでなければ例外が発生します。

//emlist[例][ruby]{
r
equire 'pathname'
Pathname
.new("/tmp").children # => [#<Pathname:.X11-unix>, #<Pathname:.iroha_unix>, ... ]
//}...

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

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

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

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

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

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

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

//emlist[例][ruby]{
r
equire 'pathname'

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

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

Pathname#entries -> [Pathname] (23389.0)

self に含まれるファイルエントリ名を元にした Pathname オブジェクトの配列を返します。

...した Pathname オブジェクトの配列を返します。

@raise Errno::EXXX self が存在しないパスであったりディレクトリでなければ例外が発生します。

//emlist[例][ruby]{
r
equire 'pathname'
r
equire 'pp'

pp Pathname('/usr/local').entries
# => [#<Pathname:.>,
#...
...#<Pathname:..>,
# #<Pathname:bin>,
# #<Pathname:etc>,
# #<Pathname:include>,
# #<Pathname:lib>,
# #<Pathname:opt>,
# #<Pathname:sbin>,
# #<Pathname:share>,
# #<Pathname:var>]
//}

@see Dir.entries...

Pathname#each_entry {|pathname| ... } -> nil (23371.0)

Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。

...r.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。


//emlist[例][ruby]{
r
equire "pathname"

Pathname
("/usr/local").each_entry {|f| p f }

# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname...
...:opt>
//}

@see Dir.foreach...
...r.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
r
equire "pathname"

Pathname
("/usr/local").each_entry {|f| p f }

# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname...
...:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}

@see Dir.foreach...

絞り込み条件を変える

Pathname#parent -> Pathname (23371.0)

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

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

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

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

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

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

Pathname#realpath -> Pathname (23360.0)

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

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

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

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

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

//emlist[例][ruby]{
r
equire '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 (23360.0)

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

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

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

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

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

//emlist[例][ruby]{
r
equire '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#realdirpath(basedir = nil) -> Pathname (23347.0)

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

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

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

//emlist[例][ruby]{
r
equire "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#dirname -> Pathname (23335.0)

Pathname.new(File.dirname(self.to_s)) と同じです。

...Pathname.new(File.dirname(self.to_s)) と同じです。

//emlist[例][ruby]{
r
equire "pathname"

Pathname
('/usr/bin/shutdown').dirname # => #<Pathname:/usr/bin>
//}

@see File.dirname...

絞り込み条件を変える

<< 1 2 3 ... > >>