Class: Saxlsx::SheetCollectionParser
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- Saxlsx::SheetCollectionParser
- Defined in:
- lib/saxlsx/sheet_collection_parser.rb
Defined Under Namespace
Classes: CurrentSheet
Class Method Summary collapse
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(file_system, shared_strings, &block) ⇒ SheetCollectionParser
constructor
A new instance of SheetCollectionParser.
- #start_element(name) ⇒ Object
Constructor Details
#initialize(file_system, shared_strings, &block) ⇒ SheetCollectionParser
Returns a new instance of SheetCollectionParser.
10 11 12 13 14 15 |
# File 'lib/saxlsx/sheet_collection_parser.rb', line 10 def initialize(file_system, shared_strings, &block) @file_system = file_system @shared_strings = shared_strings @block = block @index = -1 end |
Class Method Details
.parse(file_system, shared_strings, &block) ⇒ Object
6 7 8 |
# File 'lib/saxlsx/sheet_collection_parser.rb', line 6 def self.parse(file_system, shared_strings, &block) SaxParser.parse self.new(file_system, shared_strings, &block), file_system.workbook end |
Instance Method Details
#attr(name, value) ⇒ Object
28 29 30 |
# File 'lib/saxlsx/sheet_collection_parser.rb', line 28 def attr(name, value) @current_sheet.name = value if @current_sheet && name == :name end |
#end_element(name) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/saxlsx/sheet_collection_parser.rb', line 21 def end_element(name) if name == :sheet @block.call Sheet.new(@current_sheet.name, @current_sheet.index, @file_system, @shared_strings) @current_sheet = nil end end |
#start_element(name) ⇒ Object
17 18 19 |
# File 'lib/saxlsx/sheet_collection_parser.rb', line 17 def start_element(name) @current_sheet = CurrentSheet.new(@index += 1) if name == :sheet end |