Class: AtomicAssessmentsImport::Writer
- Inherits:
-
Object
- Object
- AtomicAssessmentsImport::Writer
- Defined in:
- lib/atomic_assessments_import/writer.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ Writer
constructor
A new instance of Writer.
- #open ⇒ Object
- #write(filename, content) ⇒ Object
Constructor Details
#initialize(path) ⇒ Writer
Returns a new instance of Writer.
7 8 9 |
# File 'lib/atomic_assessments_import/writer.rb', line 7 def initialize(path) @path = path end |
Instance Method Details
#open ⇒ Object
11 12 13 14 15 16 |
# File 'lib/atomic_assessments_import/writer.rb', line 11 def open @zip = Zip::File.open(@path, Zip::File::CREATE) yield self ensure @zip.close end |
#write(filename, content) ⇒ Object
18 19 20 21 22 |
# File 'lib/atomic_assessments_import/writer.rb', line 18 def write(filename, content) raise "Zip file is not open" unless @zip @zip.get_output_stream(filename) { |file| file.write(content) } end |