class Saxlsx::SheetCollectionParser

Constants

CurrentSheet

Public Class Methods

new(file_system, workbook, &block) click to toggle source
# File lib/saxlsx/sheet_collection_parser.rb, line 14
def initialize(file_system, workbook, &block)
  @file_system = file_system
  @workbook = workbook
  @block = block
  @index = -1
  @workbook_pr = false
end
parse(file_system, workbook, &block) click to toggle source
# File lib/saxlsx/sheet_collection_parser.rb, line 7
def self.parse(file_system, workbook, &block)
  SaxParser.parse(
    self.new(file_system, workbook, &block),
    file_system.workbook
  )
end

Public Instance Methods

attr(name, value) click to toggle source
# File lib/saxlsx/sheet_collection_parser.rb, line 46
def attr(name, value)
  if @current_sheet
    if name == :name
      @current_sheet.name = value
    end
  elsif @workbook_pr
    if name == :date1904 && value =~ /true|1/i
      @workbook.date1904 = true
    end
  end
end
end_element(name) click to toggle source
# File lib/saxlsx/sheet_collection_parser.rb, line 31
def end_element(name)
  case name
  when :sheet
    @block.call Sheet.new(
      @current_sheet.name,
      @current_sheet.index,
      @file_system,
      @workbook
    )
    @current_sheet = nil
  when :workbookPr
    @workbook_pr = false
  end
end
start_element(name) click to toggle source
# File lib/saxlsx/sheet_collection_parser.rb, line 22
def start_element(name)
  case name
  when :sheet
    @current_sheet = CurrentSheet.new(@index += 1)
  when :workbookPr
    @workbook_pr = true
  end
end