Skip to content

Instantly share code, notes, and snippets.

@jewel12
Created October 18, 2010 01:47
Show Gist options
  • Save jewel12/631569 to your computer and use it in GitHub Desktop.
Save jewel12/631569 to your computer and use it in GitHub Desktop.
fopner.rb
#!/usr/bin/ruby
# 拡張子が .gz であれば、zlib でオープンする。
require 'zlib'
module FOpener
def self.open( f_name )
f = Filename.extname(f_name) == ".gz" ? Zlib::GzipReader.open( f_name ) : File.open( f_name )
yield( f )
f.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment