Class: Ribit::FileWriter
Overview
Writer that writes to a file
Instance Method Summary collapse
-
#initialize(fileName) ⇒ FileWriter
constructor
A new instance of FileWriter.
- #write(data) ⇒ Object
Constructor Details
#initialize(fileName) ⇒ FileWriter
Returns a new instance of FileWriter.
380 381 382 383 |
# File 'lib/ribit/contentstore.rb', line 380 def initialize( fileName ) super() @fileName = fileName end |
Instance Method Details
#write(data) ⇒ Object
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/ribit/contentstore.rb', line 386 def write( data ) # get data to variable. This problems in writing XML doesn't # corrupt our file data = super( data ) stream = File.new( @fileName, 'w' ) begin stream << data stream.flush rescue Exception => exception @logger.error( 'Writing failed: ' + exception.to_s ) raise exception ensure @stream.close unless @stream.nil? end end |