るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. _builtin nil?
  2. object nil?
  3. nilclass nil?
  4. object nil
  5. _builtin nil

ライブラリ

キーワード

検索結果

Pathname#realpath(basedir = nil) -> Pathname (361.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#glob(pattern, flags=0) {|pathname| ...} -> nil (325.0)

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

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

引数の意味は、Dir.glob と同じです。 flag の初期値である 0 は「何
も指定しない」ことを意味します。

ブロックが与えられたときは、ワイルドカードにマッチした Pathname...
...ンです
@param flags パターンマッチ時のふるまいを変化させるフラグを指定します

//emlist[][ruby]{
require "pathname"
Pathname
("ruby-2.4.2").glob("R*.md") # => [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]
//}

@see Dir.glob
@see Pathname.glob...

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

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

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

引数の意味は、Dir.glob と同じです。 flag の初期値である 0 は「何
も指定しない」ことを意味します。

ブロックが与えられたときは、ワイルドカードにマッチした Pathname...
...イルドカードパターンです
@param flags パターンマッチ時のふるまいを変化させるフラグを指定します

//emlist[][ruby]{
require "pathname"
Pathname
.glob("lib/i*.rb") # => [#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]
//}

@see Dir.glob
@see Pathname#glob...

Pathname#<=>(other) -> -1 | 0 | 1 | nil (307.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#ascend {|pathname| ... } -> nil (307.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#binread(*args) -> String | nil (307.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#binwrite(string, offset=nil) -> Integer (307.0)

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

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


@see IO.binwrite

Pathname#descend {|pathname| ... } -> nil (307.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#each_entry {|pathname| ... } -> nil (307.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#each_filename {|v| ... } -> nil (307.0)

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

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

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

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

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

絞り込み条件を変える

Pathname#each_line(*args) {|line| ... } -> nil (307.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#find(ignore_error: true) {|pathname| ...} -> nil (307.0)

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

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

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

と同じです。

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

@para...

Pathname#mkpath -> nil (307.0)

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

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


@see FileUtils.#mkpath

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

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

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


@see Dir.open

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

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

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


@see IO.read

絞り込み条件を変える

Pathname#realdirpath(basedir = nil) -> Pathname (307.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#rmtree -> nil (307.0)

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

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


@see FileUtils.#rm_r

Pathname#write(string, offset=nil, **opts) -> Integer (307.0)

IO.write(self.to_s, string, offset, **opts)と同じです。

@see IO.write

Pathname#realpath -> Pathname (61.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#cleanpath(consider_symlink = false) -> Pathname (58.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#glob(pattern, flags=0) -> [Pathname] (25.0)

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

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

引数の意味は、Dir.glob と同じです。 flag の初期値である 0 は「何
も指定しない」ことを意味します。

ブロックが与えられたときは、ワイルドカードにマッチした Pathname...
...ンです
@param flags パターンマッチ時のふるまいを変化させるフラグを指定します

//emlist[][ruby]{
require "pathname"
Pathname
("ruby-2.4.2").glob("R*.md") # => [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]
//}

@see Dir.glob
@see Pathname.glob...

Pathname.glob(pattern, flags=0) -> [Pathname] (25.0)

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

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

引数の意味は、Dir.glob と同じです。 flag の初期値である 0 は「何
も指定しない」ことを意味します。

ブロックが与えられたときは、ワイルドカードにマッチした Pathname...
...イルドカードパターンです
@param flags パターンマッチ時のふるまいを変化させるフラグを指定します

//emlist[][ruby]{
require "pathname"
Pathname
.glob("lib/i*.rb") # => [#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]
//}

@see Dir.glob
@see Pathname#glob...

Pathname#ascend -> Enumerator (7.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 (7.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#each_line(*args) -> Enumerator (7.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#find(ignore_error: true) -> Enumerator (7.0)

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

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

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

と同じです。

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

@para...

Pathname#opendir -> Dir (7.0)

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

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


@see Dir.open