別のキーワード
ライブラリ
- pathname (164)
キーワード
- basename (11)
- children (11)
- cleanpath (11)
- directory? (11)
-
each
_ child (22) -
each
_ entry (13) - empty? (8)
- ftype (11)
-
make
_ symlink (11) -
relative
_ path _ from (11) - split (11)
- sticky? (11)
- symlink? (11)
- sysopen (11)
検索結果
先頭5件
-
Pathname
# empty? -> bool (12202.0) -
ディレクトリに対しては Dir.empty?(self.to_s) と同じ、他に対しては FileTest.empty?(self.to_s) と同じです。
...ては Dir.empty?(self.to_s) と同じ、他に対しては FileTest.empty?(self.to_s) と同じです。
//emlist[例 ディレクトリの場合][ruby]{
require "pathname"
require 'tmpdir'
Pathname("/usr/local").empty? # => false
Dir.mktmpdir { |dir| Pathname(dir).empty? } # => tru......e
//}
//emlist[例 ファイルの場合][ruby]{
require "pathname"
require 'tempfile'
Pathname("testfile").empty? # => false
Tempfile.create("tmp") { |tmp| Pathname(tmp).empty? } # => true
//}
@see Dir.empty?, FileTest.#empty?, Pathname#zero?... -
Pathname
# ftype -> String (12202.0) -
File.ftype(self.to_s) と同じです。
...File.ftype(self.to_s) と同じです。
@see File.ftype... -
Pathname
# sysopen(*args) -> Integer (12202.0) -
IO.sysopen(self.to_s, *args)と同じです。
...IO.sysopen(self.to_s, *args)と同じです。
@see IO.sysopen... -
Pathname
# cleanpath(consider _ symlink = false) -> Pathname (9302.0) -
余計な "."、".." や "/" を取り除いた新しい Pathname オブジェクトを返します。
...な "."、".." や "/" を取り除いた新しい Pathname オブジェクトを返します。
cleanpath は、実際にファイルシステムを参照することなく、文字列操作
だけで処理を行います。
@param consider_symlink 真ならパス要素にシンボリックリン......by]{
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
# relative _ path _ from(base _ directory) -> Pathname (9302.0) -
base_directory から self への相対パスを求め、その内容の新しい Pathname オブジェクトを生成して返します。
...irectory から self への相対パスを求め、その内容の新しい Pathname
オブジェクトを生成して返します。
パス名の解決は文字列操作によって行われ、ファイルシステムをアクセス
しません。
self が相対パスなら base_directory も相......対パスなら
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>
//}... -
Pathname
# each _ entry {|pathname| . . . } -> nil (9208.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
....to_s) {|f| yield Pathname.new(f) } と同じです。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@se......f| yield Pathname.new(f) } と同じです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:i......nclude>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Pathname
# each _ entry -> Enumerator (9108.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...f| yield Pathname.new(f) } と同じです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:i......nclude>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Pathname
# directory? -> bool (9102.0) -
FileTest.directory?(self.to_s) と同じです。
...FileTest.directory?(self.to_s) と同じです。
@see FileTest.#directory?... -
Pathname
# make _ symlink(old) -> 0 (9102.0) -
File.symlink(old, self.to_s) と同じです。
...File.symlink(old, self.to_s) と同じです。
@see File.symlink... -
Pathname
# sticky? -> bool (9102.0) -
FileTest.sticky?(self.to_s) と同じです。
...FileTest.sticky?(self.to_s) と同じです。
@see FileTest.#sticky?... -
Pathname
# symlink? -> bool (9102.0) -
FileTest.symlink?(self.to_s) と同じです。
...FileTest.symlink?(self.to_s) と同じです。
@see FileTest.#symlink?...