lib/writeexcel/biffwriter.rb in writeexcel-0.4.0 vs lib/writeexcel/biffwriter.rb in writeexcel-0.4.1
- old
+ new
@@ -11,12 +11,13 @@
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
#
require 'tempfile'
+require 'writeexcel/write_file'
-class BIFFWriter #:nodoc:
+class BIFFWriter < WriteFile #:nodoc:
BIFF_Version = 0x0600
BigEndian = [1].pack("I") == [1].pack("N")
attr_reader :byte_order, :data, :datasize
@@ -70,51 +71,10 @@
end
end
###############################################################################
#
- # _prepend($data)
- #
- # General storage function
- #
- def prepend(*args)
- d = args.join
- d = add_continue(d) if d.bytesize > @limit
-
- @datasize += d.bytesize
- @data = d + @data
-
- print "prepend\n" if defined?($debug)
- print d.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ') + "\n\n" if defined?($debug)
- d
- end
-
- ###############################################################################
- #
- # _append($data)
- #
- # General storage function
- #
- def append(*args)
- d = args.collect{ |a| a.dup.force_encoding('ASCII-8BIT') }.join
- # Add CONTINUE records if necessary
- d = add_continue(d) if d.bytesize > @limit
- if @using_tmpfile
- @filehandle.write d
- @datasize += d.bytesize
- else
- @datasize += d.bytesize
- @data = @data + d
- end
-
- print "append\n" if defined?($debug)
- print d.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ') + "\n\n" if defined?($debug)
- d
- end
-
- ###############################################################################
- #
# get_data().
#
# Retrieves data from memory in one chunk, or from disk in $buffer
# sized chunks.
#
@@ -166,11 +126,10 @@
sfo = 0x00000006
header = [record,length].pack("vv")
data = [BIFF_Version,type,build,year,bfh,sfo].pack("vvvvVV")
- print "store_bof in #{__FILE__}\n" if defined?($debug)
prepend(header, data)
end
###############################################################################
#
@@ -181,10 +140,9 @@
def store_eof
record = 0x000A
length = 0x0000
header = [record,length].pack("vv")
- print "store_eof in #{__FILE__}\n" if defined?($debug)
append(header)
end
###############################################################################
#