Class: Saxlsx::FileSystem
- Inherits:
-
Object
- Object
- Saxlsx::FileSystem
- Defined in:
- lib/saxlsx/file_system.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(filename) ⇒ FileSystem
constructor
A new instance of FileSystem.
- #shared_strings ⇒ Object
- #sheets ⇒ Object
- #workbook ⇒ Object
Constructor Details
#initialize(filename) ⇒ FileSystem
13 14 15 |
# File 'lib/saxlsx/file_system.rb', line 13 def initialize(filename) @zip = Zip::File.open filename end |
Class Method Details
.open(filename) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/saxlsx/file_system.rb', line 4 def self.open(filename) begin file_system = self.new(filename) yield file_system ensure file_system.close end end |
Instance Method Details
#close ⇒ Object
17 18 19 |
# File 'lib/saxlsx/file_system.rb', line 17 def close @zip.close end |
#shared_strings ⇒ Object
25 26 27 |
# File 'lib/saxlsx/file_system.rb', line 25 def shared_strings @zip.read('xl/sharedStrings.xml') end |
#sheets ⇒ Object
29 30 31 |
# File 'lib/saxlsx/file_system.rb', line 29 def sheets @zip.glob('xl/worksheets/sheet*.xml').sort.map{ |f| @zip.read(f).match(/<sheetData>.*<\/sheetData>/).to_s } end |
#workbook ⇒ Object
21 22 23 |
# File 'lib/saxlsx/file_system.rb', line 21 def workbook @zip.read('xl/workbook.xml').match(/<sheets>.*<\/sheets>/).to_s end |