ライブラリ
- pathname (24)
キーワード
- absolute? (1)
- ascend (1)
- basename (1)
- children (1)
- chown (1)
- descend (1)
-
each
_ child (2) -
each
_ entry (1) -
each
_ line (1) - executable? (1)
-
executable
_ real? (1) - find (2)
- lchown (1)
- mountpoint? (1)
- setuid? (1)
- sub (2)
-
sub
_ ext (1) - truncate (1)
- unlink (1)
- utime (1)
検索結果
先頭5件
-
Pathname
# utime(atime , mtime) -> Integer (37207.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
# absolute? -> bool (36607.0) -
self が絶対パス指定であれば真を返します。
...self が絶対パス指定であれば真を返します。
//emlist[例][ruby]{
require "pathname"
pathname = Pathname("/path/to/example.rb")
pathname.absolute? # => true
pathname = Pathname("../")
pathname.absolute? # => false
//}... -
Pathname
# executable? -> bool (36607.0) -
FileTest.executable?(self.to_s) と同じです。
FileTest.executable?(self.to_s) と同じです。
@see FileTest.#executable? -
Pathname
# executable _ real? -> bool (36607.0) -
FileTest.executable_real?(self.to_s) と同じです。
FileTest.executable_real?(self.to_s) と同じです。
@see FileTest.#executable_real? -
Pathname
# mountpoint? -> bool (36607.0) -
self がマウントポイントであれば真を返します。
...self がマウントポイントであれば真を返します。
//emlist[例][ruby]{
require "pathname"
path = Pathname("/")
path.mountpoint? # => true
path = Pathname("/usr")
path.mountpoint? # => false
//}... -
Pathname
# setuid? -> bool (36607.0) -
FileTest.setuid?(self.to_s) と同じです。
FileTest.setuid?(self.to_s) と同じです。
@see FileTest.#setuid? -
Pathname
# sub _ ext(replace) -> Pathname (36607.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
# truncate(length) -> 0 (36607.0) -
File.truncate(self.to_s, length) と同じです。
File.truncate(self.to_s, length) と同じです。
@param length 変更したいサイズを整数で与えます。
@see File.truncate -
Pathname
# expand _ path(default _ dir = & # 39; . & # 39;) -> Pathname (27907.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
# sub(pattern) {|matched| . . . } -> Pathname (27607.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 (27607.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
# each _ entry -> Enumerator (18607.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...yield Pathname.new(f) } と同じです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:incl......ude>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Pathname
# unlink -> Integer (18607.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) {|pathname| . . . } -> [Pathname] (10207.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
# children(with _ directory = true) -> [Pathname] (9907.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
# ascend -> Enumerator (9607.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
# basename(suffix = "") -> Pathname (9607.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
# chown(owner , group) -> Integer (9607.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
# descend -> Enumerator (9607.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 _ child(with _ directory = true) -> Enumerator (9607.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
# each _ line(*args) -> Enumerator (9607.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 (9607.0) -
self 配下のすべてのファイルやディレクトリを 一つずつ引数 pathname に渡してブロックを実行します。
...self 配下のすべてのファイルやディレクトリを
一つずつ引数 pathname に渡してブロックを実行します。
require 'find'
Find.find(self.to_s) {|f| yield Pathname.new(f)}
と同じです。
ブロックを省略した場合は Enumerator を返します。
@para... -
Pathname
# find(ignore _ error: true) {|pathname| . . . } -> nil (9607.0) -
self 配下のすべてのファイルやディレクトリを 一つずつ引数 pathname に渡してブロックを実行します。
...self 配下のすべてのファイルやディレクトリを
一つずつ引数 pathname に渡してブロックを実行します。
require 'find'
Find.find(self.to_s) {|f| yield Pathname.new(f)}
と同じです。
ブロックを省略した場合は Enumerator を返します。
@para... -
Pathname
# lchown(owner , group) -> Integer (9607.0) -
File.lchown(owner, group, self.to_s) と同じです。
File.lchown(owner, group, self.to_s) と同じです。
@param owner オーナーを指定します。
@param group グループを指定します。
@see File.lchown