るりまサーチ

最速Rubyリファレンスマニュアル検索!
858件ヒット [1-100件を表示] (0.059秒)
トップページ > クエリ:l[x] > ライブラリ:pathname[x]

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

//emlist[例][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", "li...
...e1\nline2,\nline3\n")
Pathname
("testfile").each_line {|f| p f }

# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}

//emlist[例 limit を指定][ruby]{
require "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
("testfile").each_line(",") {|f| p f }

# => "line1\nline2,"
# => "\nline3\n"
//}

@see IO.foreach...

Pathname#absolute? -> bool (6102.0)

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

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

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

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

Pathname#blockdev? -> bool (6102.0)

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

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


@see FileTest.#blockdev?...

Pathname#children(with_directory = true) -> [Pathname] (6102.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#cleanpath(consider_symlink = false) -> Pathname (6102.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
D...
...ir.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#delete -> Integer (6102.0)

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

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

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

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

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

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

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

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

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

Pathname
("/usr/local").each_child {|f| p f }
# => #<Pathname:/usr/local/bin>
# => #<Pathname:...
.../local/etc>
# => #<Pathname:/usr/local/include>
# => #<Pathname:/usr/local/lib>
# => #<Pathname:/usr/local/opt>
# => #<Pathname:/usr/local/sbin>
# => #<Pathname:/usr/local/share>
# => #<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#each_child(with_directory = true) {|pathname| ...} -> [Pathname] (6102.0)

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

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

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

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

Pathname
("/usr/local").each_child {|f| p f }
# => #<Pathname:/usr/local/bin>
# => #<Pathname:...
.../local/etc>
# => #<Pathname:/usr/local/include>
# => #<Pathname:/usr/local/lib>
# => #<Pathname:/usr/local/opt>
# => #<Pathname:/usr/local/sbin>
# => #<Pathname:/usr/local/share>
# => #<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#each_filename {|v| ... } -> nil (6102.0)

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

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

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

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

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

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

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

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

//emlist[例][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", "li...
...e1\nline2,\nline3\n")
Pathname
("testfile").each_line {|f| p f }

# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}

//emlist[例 limit を指定][ruby]{
require "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
("testfile").each_line(",") {|f| p f }

# => "line1\nline2,"
# => "\nline3\n"
//}

@see IO.foreach...

絞り込み条件を変える

<< 1 2 3 ... > >>