summaryrefslogtreecommitdiff
path: root/sample/dir.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/dir.rb')
-rw-r--r--sample/dir.rb11
1 files changed, 3 insertions, 8 deletions
diff --git a/sample/dir.rb b/sample/dir.rb
index 0c55078973..81257cd917 100644
--- a/sample/dir.rb
+++ b/sample/dir.rb
@@ -1,12 +1,7 @@
# directory access
# list all files but .*/*~/*.o
-dirp = Dir.open(".")
-for f in dirp
- case f
- when /\A\./, /~\z/, /\.o\z/
- # do not print
- else
- print f, "\n"
+Dir.foreach(".") do |file|
+ unless file.start_with?('.') or file.end_with?('~', '.o')
+ puts file
end
end
-dirp.close