るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
38件ヒット [1-38件を表示] (0.035秒)
トップページ > バージョン:2.5.0[x] > クエリ:File[x] > クラス:Pathname[x]

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file open
  4. base file
  5. file size

ライブラリ

キーワード

検索結果

Pathname#file? -> bool (18373.0)

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

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


@see FileTest.#file?

Pathname#each_filename {|v| ... } -> nil (18304.0)

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

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

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

Pathname
.new("/foo/../bar").each_filename {|v| p v}

# => "foo"
# ".."
# "bar"
//}...

Pathname#open(mode = 'r', perm = 0666) -> File (376.0)

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

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


@see File.open

Pathname#open(mode = 'r', perm = 0666) {|file| ... } -> object (376.0)

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

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


@see File.open

Pathname#lstat -> File::Stat (373.0)

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

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


@see File.lstat

絞り込み条件を変える

Pathname#stat -> File::Stat (373.0)

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

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


@see File.stat

Pathname#fnmatch(pattern, *args) -> bool (106.0)

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

...て `{}' や `**/' は使用できません。

@param args File.fnmatch を参照してください。

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

path = Pathname("testfile")
path.fnmatch("test*") # => true
path.fnmatch("TEST*") # => false
path.fnmatch("TES...

Pathname#chown(owner, group) -> Integer (88.0)

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

...

@param owner オーナーを指定します。

@param group グループを指定します。

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

Pathname
('testfile').stat.uid # => 501
Pathname
('testfile').chown(502, 12)
Pathname
('testfile').stat.uid # => 502
//}

@see File.chown, File#chown...

Pathname#fnmatch?(pattern, *args) -> bool (88.0)

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

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

@param pattern パターンを文字列で指定します。ワイルドカードとして `*', `?', `[]' が使用できま
す。Dir.glob とは違って `{}' や `**/' は使用できません。

@param args File.fnmatch を参照してください。

@see File.fnmatch?

Pathname#ascend -> Enumerator (76.0)

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

... Pathname
ブジェクトとして生成し、ブロックへの引数として渡して実行します。
ブロックを省略した場合は Enumerator を返します。

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

Pathname
.new('/path/to/some/file.rb').ascend {|v| p v}
# => #<Pathname:/path/...
...o/some/file.rb>
# #<Pathname:/path/to/some>
# #<Pathname:/path/to>
# #<Pathname:/path>
# #<Pathname:/>

Pathname
.new('path/to/some/file.rb').ascend {|v| p v}
# => #<Pathname:path/to/some/file.rb>
# #<Pathname:path/to/some>
# #<Pathname:path/to>
# #<Pathname:path>
//}

ファイ...

絞り込み条件を変える

Pathname#ascend {|pathname| ... } -> nil (76.0)

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

... Pathname
ブジェクトとして生成し、ブロックへの引数として渡して実行します。
ブロックを省略した場合は Enumerator を返します。

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

Pathname
.new('/path/to/some/file.rb').ascend {|v| p v}
# => #<Pathname:/path/...
...o/some/file.rb>
# #<Pathname:/path/to/some>
# #<Pathname:/path/to>
# #<Pathname:/path>
# #<Pathname:/>

Pathname
.new('path/to/some/file.rb').ascend {|v| p v}
# => #<Pathname:path/to/some/file.rb>
# #<Pathname:path/to/some>
# #<Pathname:path/to>
# #<Pathname:path>
//}

ファイ...

Pathname#descend -> Enumerator (76.0)

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

...
Pathname
オブジェクトとして生成し、ブロックへの引数として渡して実行しま
す。
ブロックを省略した場合は Enumerator を返します。

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

Pathname
.new('/path/to/some/file.rb').descend {|v| p v}
# => #<Pathname:/>
#...
...#<Pathname:/path>
# #<Pathname:/path/to>
# #<Pathname:/path/to/some>
# #<Pathname:/path/to/some/file.rb>

Pathname
.new('path/to/some/file.rb').descend {|v| p v}
# => #<Pathname:path>
# #<Pathname:path/to>
# #<Pathname:path/to/some>
# #<Pathname:path/to/some/file.rb>
//}

ファ...

Pathname#descend {|pathname| ... } -> nil (76.0)

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

...
Pathname
オブジェクトとして生成し、ブロックへの引数として渡して実行しま
す。
ブロックを省略した場合は Enumerator を返します。

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

Pathname
.new('/path/to/some/file.rb').descend {|v| p v}
# => #<Pathname:/>
#...
...#<Pathname:/path>
# #<Pathname:/path/to>
# #<Pathname:/path/to/some>
# #<Pathname:/path/to/some/file.rb>

Pathname
.new('path/to/some/file.rb').descend {|v| p v}
# => #<Pathname:path>
# #<Pathname:path/to>
# #<Pathname:path/to/some>
# #<Pathname:path/to/some/file.rb>
//}

ファ...

Pathname#atime -> Time (70.0)

File.atime(self.to_s) を渡したものと同じです。

...File.atime(self.to_s) を渡したものと同じです。

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

pathname
= Pathname("testfile")
pathname
.atime # => 2018-12-18 20:58:13 +0900
//}

@see File.atime...

Pathname#basename(suffix = "") -> Pathname (70.0)

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

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

@param suffix サフィックスを文字列で与えます。'.*' という文字列を与えた場合、'*' はワイルドカードとして働き
'.' を含まない任意の文字列にマッチします。

//emli...
...require "pathname"

Pathname
("ruby/ruby.c").basename #=> #<Pathname:"ruby.c">
Pathname
("ruby/ruby.c").basename(".c") #=> #<Pathname:"ruby">
Pathname
("ruby/ruby.c").basename(".*") #=> #<Pathname:"ruby">
Pathname
("ruby/ruby.exe").basename(".*") #=> #<Pathname:"ruby">
Pathname
("ruby/y....
...tab.c").basename(".*") #=> #<Pathname:"y.tab">
//}

@see File.basename...

絞り込み条件を変える

Pathname#birthtime -> Time (70.0)

File.birthtime(self.to_s) を渡したものと同じです。

File.birthtime(self.to_s) を渡したものと同じです。

@raise NotImplementedError Windows のような birthtime のない環境で発生します。


@see File.birthtime

Pathname#chmod(mode) -> Integer (70.0)

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

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

@param mode ファイルのアクセス権限を整数で指定します。


@see File.chmod

Pathname#ctime -> Time (70.0)

File.ctime(self.to_s) を渡したものと同じです。

....ctime(self.to_s) を渡したものと同じです。

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

IO.write("testfile", "test")
pathname
= Pathname("testfile")
pathname
.ctime # => 2019-01-14 00:39:51 +0900
sleep 1
pathname
.chmod(0755)
pathname
.ctime # => 2019-01-14 00:39:52 +0900
//}

@see File.ctime...

Pathname#dirname -> Pathname (70.0)

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

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

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

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

@see File.dirname...

Pathname#expand_path(default_dir = &#39;.&#39;) -> Pathname (70.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#extname -> String (70.0)

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

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


@see File.extname

Pathname#ftype -> String (70.0)

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

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


@see File.ftype

Pathname#lchmod(mode) -> Integer (70.0)

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

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

@param mode ファイルのアクセス権限を整数で指定します。


@see File.lchmod

Pathname#lchown(owner, group) -> Integer (70.0)

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

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

@param owner オーナーを指定します。

@param group グループを指定します。


@see File.lchown

Pathname#make_link(old) -> 0 (70.0)

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

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


@see File.link

絞り込み条件を変える

Pathname#make_symlink(old) -> 0 (70.0)

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

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


@see File.symlink

Pathname#mtime -> Time (70.0)

File.mtime(self.to_s) を渡したものと同じです。

File.mtime(self.to_s) を渡したものと同じです。


@see File.mtime

Pathname#readlink -> Pathname (70.0)

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

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


@see File.readlink...

Pathname#rename(to) -> 0 (70.0)

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

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

@param to ファイル名を表す文字列を指定します。


@see File.rename

Pathname#split -> Array (70.0)

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

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

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

pathname
= Pathname("/path/to/sample")
pathname
.split # => [#<Pathname:/path/to>, #<Pathname:sample>]
//}

@see File.split...

絞り込み条件を変える

Pathname#truncate(length) -> 0 (70.0)

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

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


@param length 変更したいサイズを整数で与えます。

@see File.truncate

Pathname#utime(atime, mtime) -> Integer (70.0)

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

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

@param atime 最終アクセス時刻を Time か、起算時からの経過秒数を数値で指定します。

@param mtime 更新時刻を Time か、起算時からの経過秒数を数値で指定します。


@see File.utime

Pathname#realpath -> Pathname (58.0)

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

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

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

self が指すパスが存在しない場...
...す。

//emlist[例][ruby]{
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.chd...
...ir("/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 (58.0)

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

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

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

self が指すパスが存在しない場...
...す。

//emlist[例][ruby]{
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.chd...
...ir("/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 (52.0)

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

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


@see Pathname#to_s...

絞り込み条件を変える

Pathname#cleanpath(consider_symlink = false) -> Pathname (40.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.new(path) -> Pathname (40.0)

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

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

@param path 文字列、または類似のオブジェクトを与えます。
実際には to_str に反応するオブジェクトなら何でも構いません。

@raise ArgumentError path が \0 を含んで...
...いると発生します。

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

Pathname
.new(__FILE__) # => #<Pathname:/path/to/file.rb>
//}...

Pathname#to_s -> String (22.0)

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

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


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

path = Pathname.new("/tmp/hogehoge")
File.open(path)
//}...