Class: BiffRecord
- Inherits:
-
Object
- Object
- BiffRecord
- Defined in:
- lib/surpass/biff_record.rb
Direct Known Subclasses
BackupRecord, Biff8BOFRecord, BlankRecord, BookBoolRecord, BoolErrRecord, BottomMarginRecord, BoundSheetRecord, CalcCountRecord, CalcModeRecord, CodepageBiff8Record, ColInfoRecord, ContinueRecord, CountryRecord, DSFRecord, DateModeRecord, DefColWidthRecord, DefaultRowHeight, DeltaRecord, DimensionsRecord, EOFRecord, ExtSSTRecord, ExternSheetRecord, FnGroupCountRecord, FontRecord, FooterRecord, FormulaRecord, GridSetRecord, GutsRecord, HCenterRecord, HeaderRecord, HideObjRecord, HorizontalPageBreaksRecord, ImDataBmpRecord, InterfaceEndRecord, InterfaceHeaderRecord, IterationRecord, LabelSSTRecord, LeftMarginRecord, MMSRecord, MergedCellsRecord, MulBlankRecord, NameRecord, NumberFormatRecord, NumberRecord, ObjBmpRecord, ObjectProtectRecord, PaletteRecord, PanesRecord, PasswordRecord, PrecisionRecord, PrintGridLinesRecord, PrintHeadersRecord, Prot4RevPassRecord, Prot4RevRecord, ProtectRecord, RKRecord, RefModeRecord, RefreshAllRecord, RightMarginRecord, RowRecord, SSTRecord, SaveRecalcRecord, ScenarioProtectRecord, SetupPageRecord, StyleRecord, SupBookRecord, TabIDRecord, TopMarginRecord, UseSelfsRecord, VCenterRecord, VerticalPageBreaksRecord, WSBoolRecord, Window1Record, Window2Record, WindowProtectRecord, WriteAccessRecord, XFRecord
Constant Summary collapse
- BIFF_LIMIT =
limit for BIFF7/8
0x2020
- CONTINUE_RECORD_ID =
0x003C
Instance Attribute Summary collapse
-
#record_data ⇒ Object
Returns the value of attribute record_data.
Instance Method Summary collapse
-
#initialize ⇒ BiffRecord
constructor
By default, initialize to ”.
- #record_header ⇒ Object
- #to_biff ⇒ Object
Constructor Details
#initialize ⇒ BiffRecord
By default, initialize to ”. May be overridden in subclass.
103 104 105 |
# File 'lib/surpass/biff_record.rb', line 103 def initialize @record_data = '' end |
Instance Attribute Details
#record_data ⇒ Object
Returns the value of attribute record_data.
96 97 98 |
# File 'lib/surpass/biff_record.rb', line 96 def record_data @record_data end |
Instance Method Details
#record_header ⇒ Object
107 108 109 110 |
# File 'lib/surpass/biff_record.rb', line 107 def record_header # TODO figure out if Ruby's or Python's length function is correct here. [self.class::RECORD_ID, @record_data.length].pack('v2') end |
#to_biff ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/surpass/biff_record.rb', line 112 def to_biff if @record_data.length > BIFF_LIMIT chunks = [] pos = 0 while pos < @record_data.length chunk_pos = pos + BIFF_LIMIT chunk = @record_data[pos...chunk_pos] chunks << chunk pos = chunk_pos end continues = [self.class::RECORD_ID, chunks[0].length].pack('v2') + chunks[0] chunks.each_with_index do |c, i| next if i == 0 continues += [CONTINUE_RECORD_ID, c.length].pack('v2') + c end continues else record_header + @record_data end end |