Bug #5332
Pathname#entries
| Status: | Closed | Start date: | 09/17/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | - | |||
| reporter: | ruby_version: |
Description
Pathanme#entries -> [String]
Dir.entries(self.to_s) と同じです。
とありますが、
Dir.entries(path) -> [String]
ディレクトリ path に含まれるファイルエントリ名の配列を返します。
Dir.entries(pathname.to_s) は String の配列を返しますが、
RUBY_DESCRIPTION
=> "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1]"
Pathname('/').entries
=> [#<Pathname:.>, #<Pathname:..>, ... ]
Dir.entries(Pathname('/').to_s)
=> [".", "..", ...]Pathname#entries は String ではなくPathname の配列を返すようです。つまり説明とシグネチャが共に誤りだと思われます。
Associated revisions
fix signature and description (fixes #5332)
History
Updated by no6v (Nobuhiro IMAI) 8 months ago
- Assignee set to no6v (Nobuhiro IMAI)
self がディレクトリでない場合は例外になるようですし、合わせて以下のような感じでコミットしようと思います。
diff --git a/refm/api/src/pathname.rd b/refm/api/src/pathname.rd index 7bcf0f6..6f85554 100644 --- a/refm/api/src/pathname.rd +++ b/refm/api/src/pathname.rd @@ -710,8 +710,10 @@ Dir.rmdir(self.to_s) @see [[m:Dir.rmdir]] ---- entries -> [String] -Dir.entries(self.to_s) と同じです。 +--- entries -> [Pathname] +self に含まれるファイルエントリ名を元にした [[c:Pathname]] オブジェクトの配列を返します。 + +@raise Errno::EXXX self が存在しないパスであったりディレクトリでなければ例外が発生します。 @see [[m:Dir.entries]]
Updated by okkez (okkez _) 8 months ago
- Status changed from Open to Assigned
少くとも
$ ruby-1.8.7-p352 -rpathname -e 'p Dir.entries(".").first.class'
String
な感じなので、1.8系では [String] になっています。
Updated by no6v (Nobuhiro IMAI) 8 months ago
ここは Dir.entries じゃなくて Pathname#entries の問題ですよね?
$ ruby-1.8.7-p352 -rpathname -e 'p Pathname.new(".").entries.first.class'
Pathname
Updated by okkez (okkez _) 8 months ago
おっと、失礼しました。
パッチだけ見て早とちりしました。。。
いまいさんが正しいです。
Updated by no6v (Nobuhiro IMAI) 8 months ago
ではコミットしておきます。
Updated by okkez (okkez _) 8 months ago
はい、お願いします!
Updated by no6v (Nobuhiro IMAI) 8 months ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100