Class: Rbxl::ReadOnlyWorkbook
- Inherits:
-
Object
- Object
- Rbxl::ReadOnlyWorkbook
- Defined in:
- lib/rbxl/read_only_workbook.rb
Constant Summary collapse
- MAIN_NS =
"http://schemas.openxmlformats.org/spreadsheetml/2006/main"- REL_NS =
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"- PACKAGE_REL_NS =
"http://schemas.openxmlformats.org/package/2006/relationships"
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sheet_names ⇒ Object
readonly
Returns the value of attribute sheet_names.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(path) ⇒ ReadOnlyWorkbook
constructor
A new instance of ReadOnlyWorkbook.
- #sheet(name) ⇒ Object
Constructor Details
#initialize(path) ⇒ ReadOnlyWorkbook
Returns a new instance of ReadOnlyWorkbook.
13 14 15 16 17 18 19 20 |
# File 'lib/rbxl/read_only_workbook.rb', line 13 def initialize(path) @path = path @zip = Zip::File.open(path) @shared_strings = load_shared_strings @sheet_entries = load_sheet_entries @sheet_names = @sheet_entries.keys.freeze @closed = false end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/rbxl/read_only_workbook.rb', line 7 def path @path end |
#sheet_names ⇒ Object (readonly)
Returns the value of attribute sheet_names.
7 8 9 |
# File 'lib/rbxl/read_only_workbook.rb', line 7 def sheet_names @sheet_names end |
Class Method Details
.open(path) ⇒ Object
9 10 11 |
# File 'lib/rbxl/read_only_workbook.rb', line 9 def self.open(path) new(path) end |
Instance Method Details
#close ⇒ Object
32 33 34 35 36 37 |
# File 'lib/rbxl/read_only_workbook.rb', line 32 def close return if closed? @zip.close @closed = true end |
#closed? ⇒ Boolean
39 40 41 |
# File 'lib/rbxl/read_only_workbook.rb', line 39 def closed? @closed end |
#sheet(name) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rbxl/read_only_workbook.rb', line 22 def sheet(name) ensure_open! entry_path = @sheet_entries.fetch(name) do raise SheetNotFoundError, "sheet not found: #{name}" end ReadOnlyWorksheet.new(zip: @zip, entry_path: entry_path, shared_strings: @shared_strings, name: name) end |