Ruby 1.9.0 リファレンスマニュアル > ライブラリ一覧 > pathnameライブラリ > Pathnameクラス

class Pathname

クラスの継承リスト: Pathname < Object < Kernel < BasicObject

要約

パス名クラス

特異メソッド

定義 説明
getwd -> Pathname
pwd -> Pathname

カレントディレクトリを元に Pathname オブジェクトを生成します。 Pathname.new(Dir.getwd) と同じです。

glob(pattern, flags=0) -> [Pathname]
glob(pattern, flags=0) {|pathname| ...} -> nil

ワイルドカードの展開を行なった結果を、 Pathname オブジェクトの配列として返します。

new(path) -> Pathname

文字列 path を元に Pathname オブジェクトを生成します。

インスタンスメソッド

定義 説明
self + other -> Pathname

パス名を連結します。つまり、other を self からの相対パスとした新しい Pathname オブジェクトを生成して返します。

self <=> other -> bool

パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合 は正、other が大きい場合は負を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。

self == other -> bool
self === other -> bool
eql?(other) -> bool

パス名を比較し、 other と同じなら真を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。

absolute? -> bool

self が絶対パス指定であれば真を返します。

ascend { |pathname| ... }

self のパス名から親方向に辿っていったときの各パス名を新しい Pathname オ ブジェクトとして生成し、ブロックへの引数として渡して実行します。

atime

File.atimeの第一引数に self.to_s を渡したものと同じです。

basename(*args)

Pathname.new(File.basename(self.to_s, *args)) と同じです。 (cf. File.basename)

blockdev?

FileTest.blockdev?(self.to_s) と同じです。 (cf. FileTest.#blockdev?)

chardev?

FileTest.chardev?(self.to_s) と同じです。 (cf. FileTest.#chardev?)

chdir(&block)

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

children -> [Pathname]

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

chmod(mode)

File.chmod(mode, self.to_s)と同じです。 (cf. File.chmod)

chown(owner, group)

File.chown(owner, group, self.to_s)と同じです。 (cf. File.chown)

chroot

Dir.chroot(self.to_s) と同じです。 (cf. Dir.chroot)

cleanpath(consider_symlink = false) -> Pathname

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

ctime

File.ctimeの第一引数に self.to_s を渡したものと同じです。

unlink
delete

self が指すディレクトリあるいはファイルを削除します。

descend { |pathname| ... }

self のパス名の親から子供へと辿っていったときの各パス名を新しい Pathname オブジェクトとして生成し、ブロックへの引数として渡して実行しま す。

dir_foreach {|pathname| ... }

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

directory?

FileTest.directory?(self.to_s) と同じです。 (cf. FileTest.#directory?)

dirname

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

each_entry {|pathname| ... }

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

each_filename {|v| ... } -> nil

self のパス名要素毎にブロックを実行します。

each_line(*args, &block)

IO.foreach(self.to_s, *args, &block) と同じです。 (cf. IO.foreach)

entries

Dir.entries(self.to_s) と同じです。 (cf. Dir.entries)

executable?

FileTest.executable?(self.to_s) と同じです。 (cf. FileTest.#executable?)

executable_real?

FileTest.executable_real?(self.to_s) と同じです。 (cf. FileTest.#executable_real?)

exist?

FileTest.exist?(self.to_s) と同じです。 (cf. FileTest.#exist?)

expand_path(*args)

Pathname.new(File.expand_path(self.to_s, *args)) と同じです。 (cf. File.expand_path)

extname

File.extname(self.to_s) と同じです。 (cf. File.extname)

file?

FileTest.file?(self.to_s) と同じです。 (cf. FileTest.#file?)

find {|pathname| ...}

self 配下のすべてのファイルやディレクトリを 一つずつ引数 pathname に渡してブロックを実行します。

fnmatch(pattern, *args)

File.fnmatch(pattern, self.to_s, *args)と同じです。 (cf. File.fnmatch)

fnmatch?(pattern, *args)

File.fnmatch?(pattern, self.to_s, *args) と同じです。 (cf. File.fnmatch?)

foreach(*args, &block)

self の指し示すパスがディレクトリなら Dir.foreach(self.to_s, *args, &block) と、さもなければ IO.foreach(self.to_s, *args, &block) と同じです。

foreachline(*args, &block)

IO.foreach(self.to_s, *args, &block) と同じです。 (cf. IO.foreach)

ftype

File.ftype(self.to_s) と同じです。 (cf. File.ftype)

grpowned?

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

hash -> Fixnum

ハッシュ値を返します。

join(*args)

Pathname.new(File.join(self.to_s, *args)) と同じです。 (cf. File.join)

lchmod(mode)

File.lchmod(mode, self.to_s)と同じです。 (cf. File.lchmod)

lchown(owner, group)

File.lchown(owner, group, self.to_s)と同じです。 (cf. File.lchown)

link(old)

File.link(old, self.to_s) と同じです。 (cf. File.link)

lstat

File.lstat(self.to_s) と同じです。 (cf. File.lstat)

make_link(old)

File.link(old, self.to_s) と同じです。 (cf. File.link)

make_symlink(old)

File.symlink(old, self.to_s) と同じです。 (cf. File.symlink)

mkdir(*args)

Dir.mkdir(self.to_s, *args) と同じです。 (cf. Dir.mkdir)

mkpath

FileUtils.mkpath(self.to_s) と同じです。 (cf. FileUtils.#mkpath)

mountpoint? -> bool

self がマウントポイントであれば真を返します。

mtime

File.mtimeの第一引数に self.to_s を渡したものと同じです。

open(*args, &block)

File.open(self.to_s, *args, &block) と同じです。 (cf. File.open)

opendir(&block)

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

owned?

FileTest.owned?(self.to_s) と同じです。 (cf. FileTest.#owned?)

parent -> Pathname

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

pipe?

FileTest.pipe?(self.to_s) と同じです。 (cf. FileTest.#pipe?)

read(*args)

IO.read(self.to_s, *args)と同じです。 (cf. IO.read)

readable?

FileTest.readable?(self.to_s) と同じです。 (cf. FileTest.#readable?)

readable_real?

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

readlines(*args)

IO.readlines(self.to_s, *args)と同じです。 (cf. IO.readlines)

readlink

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

realpath(force_absolute = true) -> Pathname

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

relative? -> bool

self が相対パス指定であれば真を返す。

relative_path_from(base_directory) -> Pathname

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

rename(to)

File.rename(self.to_s, to) と同じです。 (cf. File.rename)

rmdir

Dir.rmdir(self.to_s) と同じです。 (cf. Dir.rmdir)

rmtree

FileUtils.rm_r(self.to_s) と同じです。 (cf. FileUtils.#rm_r)

root? -> bool

self がルートディレクトリであれば真を返します。判断は文字列操作によっ て行われ、ファイルシステムはアクセスされません。

setgid?

FileTest.setgid?(self.to_s) と同じです。 (cf. FileTest.#setgid?)

setuid?

FileTest.setuid?(self.to_s) と同じです。 (cf. FileTest.#setuid?)

size

FileTest.size(self.to_s) と同じです。 (cf. FileTest.#size)

size?

FileTest.size?(self.to_s) と同じです。 (cf. FileTest.#size?)

socket?

FileTest.socket?(self.to_s) と同じです。 (cf. FileTest.#socket?)

split

File.split(self.to_s) と同じです。 (cf. File.split)

stat

File.stat(self.to_s) と同じです。 (cf. File.stat)

sticky?

FileTest.sticky?(self.to_s) と同じです。 (cf. FileTest.#sticky?)

sub(pattern, replace) -> Pathname
sub(pattern) {|matched| ... } -> Pathname

self を表現するパス文字列に対して sub メソッドを呼び出し、その結果を内 容とする新しい Pathname オブジェクトを生成し、返します。 cf. String#sub

symlink(old)

File.symlink(old, self.to_s) と同じです。 (cf. File.symlink)

symlink?

FileTest.symlink?(self.to_s) と同じです。 (cf. FileTest.#symlink?)

sysopen(*args)

IO.sysopen(self.to_s, *args)と同じです。 (cf. IO.sysopen)

to_path

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

to_s -> String
to_str -> String

パス名を文字列で返します。

truncate(length)

File.truncate(self.to_s, length) と同じです。 (cf. File.truncate)

utime(atime, mtime)

File.utime(atime, mtime, self.to_s) と同じです。 (cf. File.utime)

world_readable?

FileTest.world_readable?(self.to_s) と同じです。 (cf. FileTest.#world_readable?)

world_writable?

FileTest.world_writable?(self.to_s) と同じです。 (cf. FileTest.#world_writable?)

writable?

FileTest.writable?(self.to_s) と同じです。 (cf. FileTest.#writable?)

writable_real?

FileTest.writable_real?(self.to_s) と同じです。 (cf. FileTest.#writable_real?)

zero?

FileTest.zero?(self.to_s) と同じです。 (cf. FileTest.#zero?)

定数

定義 説明
SEPARATOR_PAT

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

TO_PATH

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

継承したメソッド

! != =~ __id__ __send__ _dump class clone dclone display enum_for equal? extend freeze frozen? initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_splat to_yaml to_yaml_properties to_yaml_style untaint