るりまサーチ (Ruby 2.4.0)

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

別のキーワード

  1. pathname glob
  2. pathname sub
  3. pathname find
  4. pathname open
  5. pathname ascend

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

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

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

...ruby]{
require "pathname"

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

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

@see Pathname#children...

Pathname#sub_ext(replace) -> Pathname (63595.0)

拡張子を与えられた文字列で置き換えた Pathname オブジェクトを返します。

...置き換えた Pathname オブジェクトを返します。

自身が拡張子を持たない場合は、与えられた文字列を拡張子として付加します。

@param replace 拡張子を文字列で指定します。

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

Pathname
('/usr/bin/shutdown...
...') # => #<Pathname:/usr/bin/shutdown.rb>
Pathname
('/home/user/test.txt').sub_ext('.pdf') # => #<Pathname:/home/user/test.pdf>
Pathname
('/home/user/test').sub_ext('.pdf') # => #<Pathname:/home/user/test.pdf>
Pathname
('/home/user/test.').sub_ext('.pdf') # => #<Pathname:/home/user/tes...
...t..pdf>
Pathname('/home/user/.test').sub_ext('.pdf') # => #<Pathname:/home/user/.test.pdf>
Pathname
('/home/user/test.tar.gz').sub_ext('.xz') # => #<Pathname:/home/user/test.tar.xz>
//}...

Pathname#ascend {|pathname| ... } -> nil (63577.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 {|pathname| ... } -> nil (63577.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#entries -> [Pathname] (63577.0)

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

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

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

//emlist[例][ruby]{
require 'pathname'
require '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#+(other) -> Pathname (63562.0)

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

...た新しい
Pathname
オブジェクトを生成して返します。

other が絶対パスなら単に other と同じ内容の Pathname オブジェクトが返さ
れます。

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

Pathname
("foo/bar")+"baz" # => #<Pathname:foo/bar/baz>
Pathname
("foo/bar/")+"...
...baz" # => #<Pathname:foo/bar/baz>
Pathname
("foo/bar")+"/baz" # => #<Pathname:/baz>
Pathname
("foo/bar")+"../baz" # => #<Pathname:foo/baz>
//}

@param other 文字列か Pathname オブジェクトを指定します。...

Pathname#/(other) -> Pathname (63562.0)

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

...た新しい
Pathname
オブジェクトを生成して返します。

other が絶対パスなら単に other と同じ内容の Pathname オブジェクトが返さ
れます。

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

Pathname
("foo/bar")+"baz" # => #<Pathname:foo/bar/baz>
Pathname
("foo/bar/")+"...
...baz" # => #<Pathname:foo/bar/baz>
Pathname
("foo/bar")+"/baz" # => #<Pathname:/baz>
Pathname
("foo/bar")+"../baz" # => #<Pathname:foo/baz>
//}

@param other 文字列か Pathname オブジェクトを指定します。...

Pathname#basename(suffix = "") -> Pathname (63559.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#each_entry {|pathname| ... } -> nil (63523.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>
//}

@see...

Pathname#parent -> Pathname (63523.0)

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

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

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

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

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

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

絞り込み条件を変える

Pathname#cleanpath(consider_symlink = false) -> Pathname (63505.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#expand_path(default_dir = &#39;.&#39;) -> Pathname (63469.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#realdirpath(basedir = nil) -> Pathname (63451.0)

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

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

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

//emlist[例][ruby]{
require "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...

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

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

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

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

self が相対パスなら base_directory...
...リを表す Pathname オブジェクトを指定します。

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

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

path = Pathname.new("/tmp/fo...
...o")
base = Pathname.new("/tmp")

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

Pathname#realpath -> Pathname (63436.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 (63436.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#children(with_directory = true) -> [Pathname] (63433.0)

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

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

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

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

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

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

Pathname#join(*args) -> Pathname (63421.0)

与えられたパス名を連結します。

...[ruby]{
require "pathname"

path0 = Pathname("/usr") # Pathname:/usr
path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
# 上記の path0 の処理は下記の path1 と同様のパスになります
path1 = Pathname("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
pa...

Pathname#sub(pattern) {|matched| ... } -> Pathname (63418.0)

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

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

@param pattern 置き換える文字列のパターンを指定します。

@param replace pattern で指定した文字列と置き換える文字列を指定します。

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

path1 = Pathname('/usr...
.../bin/perl')
path1.sub('perl', 'ruby') #=> #<Pathname:/usr/bin/ruby>
//}

@see String#sub...

Pathname#sub(pattern, replace) -> Pathname (63418.0)

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

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

@param pattern 置き換える文字列のパターンを指定します。

@param replace pattern で指定した文字列と置き換える文字列を指定します。

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

path1 = Pathname('/usr...
.../bin/perl')
path1.sub('perl', 'ruby') #=> #<Pathname:/usr/bin/ruby>
//}

@see String#sub...

絞り込み条件を変える

Pathname#dirname -> Pathname (63415.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#find(ignore_error: true) {|pathname| ...} -> nil (63379.0)

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

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

require 'find'
Find.find(self.to_s) {|f| yield Pathname.new(f)}

と同じです。

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

@para...

Pathname#each_child(with_directory = true) -> Enumerator (63376.0)

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

...ruby]{
require "pathname"

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

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

@see Pathname#children...

Pathname#readlink -> Pathname (63361.0)

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

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


@see File.readlink...

Pathname#ascend -> Enumerator (63277.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 (63277.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#<=>(other) -> -1 | 0 | 1 | nil (63202.0)

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

...other は Pathname オブジェクトでなければなりません。

パス名の比較は単純にパス文字列の比較によって行われるので、論理的に
同じパスでもパス文字列が違えば異なると判断されます。

@param other 比較対象の Pathname オブジ...
...ェクトを指定します。

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

p Pathname.new("foo/bar") <=> Pathname.new("foo/bar")
p Pathname.new("foo/bar") <=> Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") <=> Pathname.new("foo/bar")
# => 0
# 1
# -1
//}...

Pathname#==(other) -> bool (63202.0)

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

...other は Pathname オブジェクトでなければなりません。

パス名の比較は単純にパス文字列の比較によって行われるので、論理的に
同じパスでもパス文字列が違えば異なると判断されます。

@param other 比較対象の Pathname オブジ...
...ェクトを指定します。

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

p Pathname.new("foo/bar") == Pathname.new("foo/bar")
p Pathname.new("foo/bar") == Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") == Pathname.new("foo/bar")

# => true
# false
# false
//}...

Pathname#===(other) -> bool (63202.0)

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

...other は Pathname オブジェクトでなければなりません。

パス名の比較は単純にパス文字列の比較によって行われるので、論理的に
同じパスでもパス文字列が違えば異なると判断されます。

@param other 比較対象の Pathname オブジ...
...ェクトを指定します。

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

p Pathname.new("foo/bar") == Pathname.new("foo/bar")
p Pathname.new("foo/bar") == Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") == Pathname.new("foo/bar")

# => true
# false
# false
//}...

Pathname#eql?(other) -> bool (63202.0)

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

...other は Pathname オブジェクトでなければなりません。

パス名の比較は単純にパス文字列の比較によって行われるので、論理的に
同じパスでもパス文字列が違えば異なると判断されます。

@param other 比較対象の Pathname オブジ...
...ェクトを指定します。

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

p Pathname.new("foo/bar") == Pathname.new("foo/bar")
p Pathname.new("foo/bar") == Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") == Pathname.new("foo/bar")

# => true
# false
# false
//}...

絞り込み条件を変える

Pathname#each_line(*args) -> Enumerator (63154.0)

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

...t[例][ruby]{
require "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}

//emlist[例 ブロックを指定][ruby]{
require "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("testfile").each_line...
...uire "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("testfile").each_line(4) {|f| p f }

# => "line"
# => "1\n"
# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}

//emlist[例 sep を指定][ruby]{
require "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("tes...

Pathname#each_line(*args) {|line| ... } -> nil (63154.0)

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

...t[例][ruby]{
require "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}

//emlist[例 ブロックを指定][ruby]{
require "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("testfile").each_line...
...uire "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("testfile").each_line(4) {|f| p f }

# => "line"
# => "1\n"
# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}

//emlist[例 sep を指定][ruby]{
require "pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname
("tes...

Pathname#absolute? -> bool (63136.0)

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

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

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

pathname
= Pathname("/path/to/example.rb")
pathname
.absolute? # => true
pathname
= Pathname("../")
pathname
.absolute? # => false
//}...

Pathname#empty? -> bool (63136.0)

ディレクトリに対しては Dir.empty?(self.to_s) と同じ、他に対しては FileTest.empty?(self.to_s) と同じです。

...トリの場合][ruby]{
require "pathname"
require 'tmpdir'

Pathname
("/usr/local").empty? # => false
Dir.mktmpdir { |dir| Pathname(dir).empty? } # => true
//}

//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#binread(*args) -> String | nil (63118.0)

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

...じです。

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

pathname
= Pathname("testfile")
pathname
.binread # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
pathname
.binread(20) # => "This is line one\nThi"
pathname
.binread(20, 10) # => "ne one\nThis is lin...

絞り込み条件を変える

Pathname#ctime -> Time (63118.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#delete -> Integer (63118.0)

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

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

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

pathname
= Pathname("/path/to/sample")
pathname
.exist? # => true
pathname
.unlink # => 1
pathname
.exist? # => false
//}...

Pathname#split -> Array (63118.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#unlink -> Integer (63118.0)

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

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

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

pathname
= Pathname("/path/to/sample")
pathname
.exist? # => true
pathname
.unlink # => 1
pathname
.exist? # => false
//}...

Pathname#atime -> Time (63082.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#chown(owner, group) -> Integer (63082.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#find(ignore_error: true) -> Enumerator (63079.0)

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

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

require 'find'
Find.find(self.to_s) {|f| yield Pathname.new(f)}

と同じです。

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

@para...

Pathname#to_path -> String (63076.0)

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

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


@see Pathname#to_s...

Pathname#mountpoint? -> bool (63064.0)

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

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

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

path = Pathname("/")
path.mountpoint? # => true
path = Pathname("/usr")
path.mountpoint? # => false
//}...

Pathname#relative? -> bool (63064.0)

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

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

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

p = Pathname.new('/im/sure')
p.relative? #=> false

p = Pathname.new('not/so/sure')
p.relative? #=> true
//}...

絞り込み条件を変える

Pathname#root? -> bool (63064.0)

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

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

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

Pathname
('/').root? # => true
Pathname
('/im/sure').root? # => false
//}...

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

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

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

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

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

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

Pathname#fnmatch(pattern, *args) -> bool (63046.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#to_s -> String (63046.0)

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

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


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

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

Pathname#zero? -> bool (63028.0)

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

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


@see FileTest.#zero?
, Pathname#empty?...

絞り込み条件を変える

Pathname#binwrite(string, offset=nil) -> Integer (63010.0)

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

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


@see IO.binwrite

Pathname#birthtime -> Time (63010.0)

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

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

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


@see File.birthtime

Pathname#blockdev? -> bool (63010.0)

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

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


@see FileTest.#blockdev?

Pathname#chardev? -> bool (63010.0)

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

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


@see FileTest.#chardev?

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

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

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

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


@see File.chmod

絞り込み条件を変える

Pathname#directory? -> bool (63010.0)

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

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


@see FileTest.#directory?

Pathname#executable? -> bool (63010.0)

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

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


@see FileTest.#executable?

Pathname#executable_real? -> bool (63010.0)

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

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


@see FileTest.#executable_real?

Pathname#exist? -> bool (63010.0)

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

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


@see FileTest.#exist?

Pathname#extname -> String (63010.0)

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

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


@see File.extname

絞り込み条件を変える

Pathname#file? -> bool (63010.0)

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

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


@see FileTest.#file?

Pathname#fnmatch?(pattern, *args) -> bool (63010.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#ftype -> String (63010.0)

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

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


@see File.ftype

Pathname#grpowned? -> bool (63010.0)

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

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


@see FileTest.#grpowned?

Pathname#hash -> Integer (63010.0)

ハッシュ値を返します。

ハッシュ値を返します。

絞り込み条件を変える

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

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

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

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


@see File.lchmod

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

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

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

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

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


@see File.lchown

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

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

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


@see File.lstat

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

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

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


@see File.link

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

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

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


@see File.symlink

絞り込み条件を変える

Pathname#mkdir(*args) -> 0 (63010.0)

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

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


@see Dir.mkdir

Pathname#mkpath -> nil (63010.0)

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

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


@see FileUtils.#mkpath

Pathname#mtime -> Time (63010.0)

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

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


@see File.mtime

Pathname#open(mode = &#39;r&#39;, perm = 0666) -> File (63010.0)

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

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


@see File.open

Pathname#open(mode = &#39;r&#39;, perm = 0666) {|file| ... } -> object (63010.0)

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

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


@see File.open

絞り込み条件を変える

Pathname#opendir -> Dir (63010.0)

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

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


@see Dir.open

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

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

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


@see Dir.open

Pathname#owned? -> bool (63010.0)

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

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


@see FileTest.#owned?

Pathname#pipe? -> bool (63010.0)

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

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


@see FileTest.#pipe?

Pathname#read(*args) -> String | nil (63010.0)

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

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


@see IO.read

絞り込み条件を変える

Pathname#readable? -> bool (63010.0)

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

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


@see FileTest.#readable?

Pathname#readable_real? -> bool (63010.0)

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

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


@see FileTest.#readable_real?

Pathname#readlines(*args) -> [String] (63010.0)

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

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


@see IO.readlines

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

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

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

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


@see File.rename

Pathname#rmdir -> 0 (63010.0)

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

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


@see Dir.rmdir

絞り込み条件を変える

Pathname#rmtree -> nil (63010.0)

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

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


@see FileUtils.#rm_r

Pathname#setgid? -> bool (63010.0)

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

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


@see FileTest.#setgid?

Pathname#setuid? -> bool (63010.0)

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

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


@see FileTest.#setuid?

Pathname#size -> Integer (63010.0)

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

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


@see FileTest.#size

Pathname#size? -> bool (63010.0)

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

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


@see FileTest.#size?

絞り込み条件を変える

Pathname#socket? -> bool (63010.0)

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

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


@see FileTest.#socket?

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

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

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


@see File.stat

Pathname#sticky? -> bool (63010.0)

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

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


@see FileTest.#sticky?

Pathname#symlink? -> bool (63010.0)

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

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


@see FileTest.#symlink?

Pathname#sysopen(*args) -> Integer (63010.0)

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

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


@see IO.sysopen

絞り込み条件を変える

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

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

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


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

@see File.truncate

Pathname#utime(atime, mtime) -> Integer (63010.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#world_readable? -> bool (63010.0)

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

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


@see FileTest.#world_readable?

Pathname#world_writable? -> bool (63010.0)

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

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


@see FileTest.#world_writable?

Pathname#writable? -> bool (63010.0)

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

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


@see FileTest.#writable?

絞り込み条件を変える

<< 1 2 > >>