Class: ReadXls::RecordHandler::Format

Inherits:
Base
  • Object
show all
Defined in:
lib/read_xls/record_handler/format.rb

Constant Summary collapse

F_HIGH_BYTE =
0x01

Instance Attribute Summary

Attributes inherited from Base

#biff, #builder, #record_data, #record_number

Instance Method Summary collapse

Methods inherited from Base

call, #initialize

Constructor Details

This class inherits a constructor from ReadXls::RecordHandler::Base

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/read_xls/record_handler/format.rb', line 6

def call
  index, char_count, grbit = record_data
                               .byteslice(0, 5)
                               .unpack("v2C")

  char_byte_size = (grbit & F_HIGH_BYTE) == 0 ? 1 : 2

  string_length = char_count * char_byte_size
  format_string = record_data.byteslice(5, string_length)

  builder.add_format(index, format_string)
end