Class: Xlsxtream::IO::RubyZip

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

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ RubyZip

Returns a new instance of RubyZip.



7
8
9
10
11
12
13
14
# File 'lib/xlsxtream/io/rubyzip.rb', line 7

def initialize(io)
  unless io.respond_to? :pos and io.respond_to? :pos=
    raise Error, 'IO is not seekable'
  end
  io.binmode if io.respond_to? :binmode
  stream = true
  @zos = Zip::OutputStream.new(io, stream)
end

Instance Method Details

#<<(data) ⇒ Object



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

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

#add_file(path) ⇒ Object



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

def add_file(path)
  @zos.put_next_entry path
end

#closeObject



24
25
26
27
# File 'lib/xlsxtream/io/rubyzip.rb', line 24

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