Class: OoxmlParser::StyleSheet

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb

Overview

Parsing file styles.xml

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ StyleSheet

Returns a new instance of StyleSheet.



14
15
16
17
18
19
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb', line 14

def initialize(parent: nil)
  @number_formats = NumberFormats.new(parent: self)
  @fonts = Fonts.new(parent: self)
  @fills = Fills.new(parent: self)
  @parent = parent
end

Instance Attribute Details

#fillsFills

Returns fills.

Returns:



12
13
14
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb', line 12

def fills
  @fills
end

#fontsFonts

Returns fonts.

Returns:



10
11
12
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb', line 10

def fonts
  @fonts
end

#number_formatsNumberFormats

Returns number formats.

Returns:



8
9
10
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb', line 8

def number_formats
  @number_formats
end

Instance Method Details

#parseObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb', line 21

def parse
  doc = Nokogiri::XML(File.open("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/styles.xml"))
  doc.root.xpath('*').each do |node_child|
    case node_child.name
    when 'numFmts'
      @number_formats.parse(node_child)
    when 'fonts'
      @fonts.parse(node_child)
    when 'fills'
      @fills.parse(node_child)
    end
  end
  self
end