Class: WriteFile
- Inherits:
-
Object
- Object
- WriteFile
- Defined in:
- lib/zipf/fileutil.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(fn, encoding = 'utf-8') ⇒ WriteFile
constructor
A new instance of WriteFile.
- #write(s) ⇒ Object
Constructor Details
#initialize(fn, encoding = 'utf-8') ⇒ WriteFile
Returns a new instance of WriteFile.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/zipf/fileutil.rb', line 69 def initialize fn, encoding='utf-8' if fn.split('.').last == 'gz' @f = Zlib::GzipWriter.new(File.new(fn, 'wb+'), :external_encoding=>encoding) elsif fn == '-' @f = STDOUT STDOUT.set_encoding encoding else @f = File.new fn, 'w+' @f.set_encoding encoding end end |
Class Method Details
Instance Method Details
#close ⇒ Object
91 92 93 |
# File 'lib/zipf/fileutil.rb', line 91 def close @f.close if @f!=STDIN end |
#write(s) ⇒ Object
81 82 83 |
# File 'lib/zipf/fileutil.rb', line 81 def write s @f.write s end |