Class: Xlsxtream::IO::RubyZip

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsxtream/io/rubyzip.rb

Defined Under Namespace

Classes: StreamingDeflater, UnbufferedZipOutputStream

Instance Method Summary collapse

Constructor Details

#initialize(path_or_io) ⇒ RubyZip

Returns a new instance of RubyZip.



6
7
8
9
10
# File 'lib/xlsxtream/io/rubyzip.rb', line 6

def initialize(path_or_io)
  stream = path_or_io.respond_to? :reopen
  path_or_io.binmode if path_or_io.respond_to? :binmode
  @zos = UnbufferedZipOutputStream.new(path_or_io, stream)
end

Instance Method Details

#<<(data) ⇒ Object



12
13
14
# File 'lib/xlsxtream/io/rubyzip.rb', line 12

def <<(data)
  @zos << data
end

#add_file(path) ⇒ Object



16
17
18
# File 'lib/xlsxtream/io/rubyzip.rb', line 16

def add_file(path)
  @zos.put_next_entry path
end

#closeObject



20
21
22
23
24
# File 'lib/xlsxtream/io/rubyzip.rb', line 20

def close
  os = @zos.close_buffer
  os.flush if os.respond_to? :flush
  os.close if os.respond_to? :close
end