Class: AtomicAssessmentsImport::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/atomic_assessments_import/writer.rb

Instance Method Summary collapse

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

#openObject



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