Created
October 18, 2010 01:47
-
-
Save jewel12/631569 to your computer and use it in GitHub Desktop.
fopner.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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