Skip to content

Instantly share code, notes, and snippets.

@wbailey
Created December 28, 2010 08:21
Show Gist options
  • Save wbailey/757050 to your computer and use it in GitHub Desktop.
Save wbailey/757050 to your computer and use it in GitHub Desktop.
Looping through files in a poor way
Dir['*'].each do |file|
gzip = false
if file.match(/\.gz$/)
use_file = file.sub(/\.gz$/)
gzip = true
else
use_file = file
end
IO.foreach(use_file) do |line|
#...
end
system("gzip #{use_file}") if gzip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment