Class: BIFFWriter
- Inherits:
-
Object
- Object
- BIFFWriter
- Defined in:
- lib/spreadsheet/biffwriter.rb
Constant Summary collapse
- BIFF_Version =
0x0500
- BigEndian =
[1].pack("I") == [1].pack("N")
Instance Attribute Summary collapse
-
#byte_order ⇒ Object
readonly
Returns the value of attribute byte_order.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#datasize ⇒ Object
readonly
Returns the value of attribute datasize.
Instance Method Summary collapse
- #append(*args) ⇒ Object
-
#initialize(*args) ⇒ BIFFWriter
constructor
The args here aren’t used by BIFFWriter, but they are needed by its subclasses.
- #prepend(*args) ⇒ Object
- #store_bof(type = 0x0005) ⇒ Object
- #store_eof ⇒ Object
Constructor Details
#initialize(*args) ⇒ BIFFWriter
The args here aren’t used by BIFFWriter, but they are needed by its subclasses. I don’t feel like creating multiple constructors.
12 13 14 15 |
# File 'lib/spreadsheet/biffwriter.rb', line 12 def initialize(*args) @data = "" @datasize = 0 end |
Instance Attribute Details
#byte_order ⇒ Object (readonly)
Returns the value of attribute byte_order.
6 7 8 |
# File 'lib/spreadsheet/biffwriter.rb', line 6 def byte_order @byte_order end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/spreadsheet/biffwriter.rb', line 6 def data @data end |
#datasize ⇒ Object (readonly)
Returns the value of attribute datasize.
6 7 8 |
# File 'lib/spreadsheet/biffwriter.rb', line 6 def datasize @datasize end |
Instance Method Details
#append(*args) ⇒ Object
22 23 24 25 |
# File 'lib/spreadsheet/biffwriter.rb', line 22 def append(*args) @data << args.join @datasize += args.join.length end |
#prepend(*args) ⇒ Object
17 18 19 20 |
# File 'lib/spreadsheet/biffwriter.rb', line 17 def prepend(*args) @data = args.join << @data @datasize += args.join.length end |
#store_bof(type = 0x0005) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/spreadsheet/biffwriter.rb', line 27 def store_bof(type = 0x0005) record = 0x0809 length = 0x0008 build = 0x096C year = 0x07C9 header = [record,length].pack("vv") data = [BIFF_Version,type,build,year].pack("vvvv") prepend(header, data) end |
#store_eof ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/spreadsheet/biffwriter.rb', line 39 def store_eof record = 0x000A length = 0x0000 header = [record,length].pack("vv") append(header) end |