Class: RubyXL::WorkbookRoot
- Inherits:
-
Object
- Object
- RubyXL::WorkbookRoot
- Includes:
- RelationshipSupport
- Defined in:
- lib/rubyXL/objects/root.rb
Instance Attribute Summary collapse
-
#content_types ⇒ Object
Returns the value of attribute content_types.
-
#core_properties ⇒ Object
Returns the value of attribute core_properties.
-
#custom_properties ⇒ Object
Returns the value of attribute custom_properties.
-
#document_properties ⇒ Object
Returns the value of attribute document_properties.
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#rels_hash ⇒ Object
Returns the value of attribute rels_hash.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
-
#workbook ⇒ Object
Returns the value of attribute workbook.
Attributes included from RelationshipSupport
#generic_storage, #relationship_container
Class Method Summary collapse
Instance Method Summary collapse
Methods included from RelationshipSupport
#collect_related_objects, #load_relationships, #store_relationship
Instance Attribute Details
#content_types ⇒ Object
Returns the value of attribute content_types.
9 10 11 |
# File 'lib/rubyXL/objects/root.rb', line 9 def content_types @content_types end |
#core_properties ⇒ Object
Returns the value of attribute core_properties.
8 9 10 |
# File 'lib/rubyXL/objects/root.rb', line 8 def core_properties @core_properties end |
#custom_properties ⇒ Object
Returns the value of attribute custom_properties.
8 9 10 |
# File 'lib/rubyXL/objects/root.rb', line 8 def custom_properties @custom_properties end |
#document_properties ⇒ Object
Returns the value of attribute document_properties.
8 9 10 |
# File 'lib/rubyXL/objects/root.rb', line 8 def document_properties @document_properties end |
#filepath ⇒ Object
Returns the value of attribute filepath.
7 8 9 |
# File 'lib/rubyXL/objects/root.rb', line 7 def filepath @filepath end |
#rels_hash ⇒ Object
Returns the value of attribute rels_hash.
9 10 11 |
# File 'lib/rubyXL/objects/root.rb', line 9 def rels_hash @rels_hash end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
8 9 10 |
# File 'lib/rubyXL/objects/root.rb', line 8 def thumbnail @thumbnail end |
#workbook ⇒ Object
Returns the value of attribute workbook.
8 9 10 |
# File 'lib/rubyXL/objects/root.rb', line 8 def workbook @workbook end |
Class Method Details
.default ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rubyXL/objects/root.rb', line 32 def self.default obj = self.new obj.document_properties = RubyXL::DocumentPropertiesFile.new obj.core_properties = RubyXL::CorePropertiesFile.new obj.relationship_container = RubyXL::RootRelationships.new obj.content_types = RubyXL::ContentTypes.new obj end |
.parse_file(xl_file_path, opts) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubyXL/objects/root.rb', line 41 def self.parse_file(xl_file_path, opts) raise 'Not .xlsx or .xlsm excel file' unless opts[:skip_filename_check] || %w{.xlsx .xlsm}.include?(File.extname(xl_file_path)) ::Zip::File.open(xl_file_path) { |zip_file| root = self.new root.filepath = xl_file_path root.content_types = RubyXL::ContentTypes.parse_file(zip_file) root.load_relationships(zip_file) root.workbook.root = root root } end |
Instance Method Details
#attach_relationship(rid, rf) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubyXL/objects/root.rb', line 21 def attach_relationship(rid, rf) case rf when RubyXL::ThumbnailFile then self.thumbnail = rf when RubyXL::CorePropertiesFile then self.core_properties = rf when RubyXL::DocumentPropertiesFile then self.document_properties = rf when RubyXL::CustomPropertiesFile then self.custom_properties = rf when RubyXL::Workbook then self.workbook = rf else store_relationship(rf, :unknown) end end |
#related_objects ⇒ Object
13 14 15 |
# File 'lib/rubyXL/objects/root.rb', line 13 def [ content_types, thumbnail, core_properties, document_properties, workbook ] end |
#relationship_file_class ⇒ Object
17 18 19 |
# File 'lib/rubyXL/objects/root.rb', line 17 def relationship_file_class RubyXL::RootRelationships end |