class ReadXls::RecordHandler::Boundsheet

Attributes

position[RW]

Public Instance Methods

call() click to toggle source
# File lib/read_xls/record_handler/boundsheet.rb, line 6
def call
  worksheet_builder = ::ReadXls::Workbook::WorksheetBuilder.new
  offset            = record_data.unpack("v").first
  self.position     = offset

  loop do
    record_number = read_byte
    break if record_number == ::ReadXls::RecordHandler::EOF

    record_length = read_byte
    record_data   = read_data(record_length)

    ::ReadXls::RecordHandler.call(
      record_number,
      worksheet_builder,
      biff,
      record_data
    )
  end

  builder.add_worksheet_builder(worksheet_builder)
end
read_byte() click to toggle source
# File lib/read_xls/record_handler/boundsheet.rb, line 36
def read_byte
  val           = biff.byteslice(position, 2).unpack("v")
  self.position += 2
  val.first || raise(ParsingFailedError, "expected to get value, got nil")
end
read_data(bytes) click to toggle source
# File lib/read_xls/record_handler/boundsheet.rb, line 29
def read_data(bytes)
  val           = biff.byteslice(position, bytes)
  self.position += bytes
  val
end