* lib/pathname.rb (each_filename): return Enumerator if no block
given. * test/pathname/test_pathname.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1c9b4b8c74
commit
f398d750ea
@ -1,3 +1,10 @@
|
|||||||
|
Tue Sep 23 09:01:15 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* lib/pathname.rb (each_filename): return Enumerator if no block
|
||||||
|
given.
|
||||||
|
|
||||||
|
* test/pathname/test_pathname.rb: add a test for above.
|
||||||
|
|
||||||
Tue Sep 23 08:25:56 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Sep 23 08:25:56 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* hash.c (env_aset): allow nil value to remove an entry.
|
* hash.c (env_aset): allow nil value to remove an entry.
|
||||||
|
@ -517,6 +517,7 @@ class Pathname
|
|||||||
# # yields "usr", "bin", and "ruby".
|
# # yields "usr", "bin", and "ruby".
|
||||||
#
|
#
|
||||||
def each_filename # :yield: filename
|
def each_filename # :yield: filename
|
||||||
|
return to_enum(__method__) unless block_given?
|
||||||
prefix, names = split_names(@path)
|
prefix, names = split_names(@path)
|
||||||
names.each {|filename| yield filename }
|
names.each {|filename| yield filename }
|
||||||
nil
|
nil
|
||||||
|
@ -481,6 +481,7 @@ class TestPathname < Test::Unit::TestCase
|
|||||||
result = []
|
result = []
|
||||||
Pathname.new("/usr/bin/ruby").each_filename {|f| result << f }
|
Pathname.new("/usr/bin/ruby").each_filename {|f| result << f }
|
||||||
assert_equal(%w[usr bin ruby], result)
|
assert_equal(%w[usr bin ruby], result)
|
||||||
|
assert_equal(%w[usr bin ruby], Pathname.new("/usr/bin/ruby").each_filename.to_a)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_kernel_pathname
|
def test_kernel_pathname
|
||||||
|
Loading…
x
Reference in New Issue
Block a user