Class: ReadXls::RecordHandler::MulRk

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

Constant Summary collapse

RKREC_SIZE =
6
RK_DATA_OFFSET =
4

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



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/read_xls/record_handler/mul_rk.rb', line 7

def call
  row, column_offset = record_data
                         .byteslice(0, 4)
                         .unpack("v2")
  last_column        = record_data[-2, 2].unpack("v").first
  number_of_columns  = last_column - column_offset + 1
  rk_data            = record_data[RK_DATA_OFFSET..-3]

  number_of_columns.times.each do |column_index|
    rk_rec            = rk_data[(column_index * RKREC_SIZE), RKREC_SIZE]
    ix_index, rk_bits = rk_rec.byteslice(0, RKREC_SIZE).unpack("vV")

    rk_column = ::ReadXls::Evaluator::RkNumber.new(builder, rk_bits, ix_index)

    builder.add_column_to_row(
      row,
      column_index + column_offset,
      rk_column
    )
  end
end