種類
- インスタンスメソッド (1144)
- 特異メソッド (55)
- 定数 (22)
- クラス (11)
クラス
- Pathname (1210)
モジュール
- Kernel (11)
キーワード
- + (11)
-
/ (10) - <=> (11)
- == (11)
- === (11)
-
SEPARATOR
_ PAT (11) -
TO
_ PATH (11) - absolute? (11)
- ascend (22)
- atime (11)
- basename (11)
- binread (11)
- binwrite (11)
- birthtime (10)
- blockdev? (11)
- chardev? (11)
- children (11)
- chmod (11)
- chown (11)
- cleanpath (11)
- ctime (11)
- delete (11)
- descend (22)
- directory? (11)
- dirname (11)
-
each
_ child (22) -
each
_ entry (13) -
each
_ filename (11) -
each
_ line (22) - empty? (8)
- entries (11)
- eql? (11)
- executable? (11)
-
executable
_ real? (11) - exist? (11)
- extname (11)
- file? (11)
- find (22)
- fnmatch (11)
- fnmatch? (11)
- ftype (11)
- getwd (11)
- glob (36)
- grpowned? (11)
- hash (11)
- join (11)
- lchmod (11)
- lchown (11)
- lstat (11)
-
make
_ link (11) -
make
_ symlink (11) - mkdir (11)
- mkpath (11)
- mountpoint? (11)
- mtime (11)
- new (11)
- open (22)
- opendir (22)
- owned? (11)
- parent (11)
- pipe? (11)
- pwd (11)
- read (11)
- readable? (11)
-
readable
_ real? (11) - readlines (11)
- readlink (11)
- realdirpath (11)
- realpath (22)
- relative? (11)
-
relative
_ path _ from (11) - rename (11)
- rmdir (11)
- rmtree (11)
- root? (11)
- setgid? (11)
- setuid? (11)
- size (11)
- size? (11)
- socket? (11)
- split (11)
- stat (11)
- sticky? (11)
- sub (22)
-
sub
_ ext (11) - symlink? (11)
- sysopen (11)
-
to
_ path (11) -
to
_ s (11) - truncate (11)
- unlink (11)
- utime (11)
-
world
_ readable? (11) -
world
_ writable? (11) - writable? (11)
-
writable
_ real? (11) - write (11)
- zero? (11)
検索結果
先頭5件
-
Pathname (38080.0)
-
パス名をオブジェクト指向らしく扱うクラスです。
...クラスです。
Pathname オブジェクトはパス名を表しており、ファイルやディレクトリそのものを表してはいません。
当然、存在しないファイルのパス名も扱えます。
絶対パスも相対パスも扱えます。
Pathname オブジェクト......るメソッドはありません。
Pathname のインスタンスメソッドには、ディレクトリのパスを返す Pathname#dirname のように、
文字列操作だけで結果を返すものもあれば、ファイルの中身を読み出す Pathname#read のように
ファイルシ......ムにアクセスするものもあります。
Pathname オブジェクトの生成には、Pathname.new のほかに Kernel#Pathname も使えます。
//emlist[例][ruby]{
require 'pathname'
Pathname.new("foo/bar") # => #<Pathname:foo/bar>
Pathname("foo/bar") # => #<Pathname:foo/bar>
//}... -
Pathname
# each _ child(with _ directory = true) {|pathname| . . . } -> [Pathname] (21324.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 (21197.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 (21191.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 (21191.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] (21191.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 (21186.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 (21186.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 (21185.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 (21185.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 (21173.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...