Sha256: ea33dd4eb5c51337a8f9a6517179fc34cccb757150dccc9d3ca6a07da292c462

Contents?: true

Size: 905 Bytes

Versions: 4

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

require_relative 'styles/document_defaults'
module OoxmlParser
  # Class for parsing `styles.xml` file
  class Styles < OOXMLDocumentObject
    # @return [DocumentDefaults] defaults of document
    attr_accessor :document_defaults
    # @return [Array<DocumentStyle>] array of document styles
    attr_reader :styles

    def initialize(parent: nil)
      @styles = []
      super
    end

    # Parse styles data
    # @return [Styles] result of parsing
    def parse
      doc = parse_xml("#{root_object.unpacked_folder}word/styles.xml")
      doc.xpath('w:styles/*').each do |node_child|
        case node_child.name
        when 'docDefaults'
          @document_defaults = DocumentDefaults.new(parent: self).parse(node_child)
        when 'style'
          @styles << DocumentStyle.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ooxml_parser-0.33.0 lib/ooxml_parser/docx_parser/document_structure/styles.rb
ooxml_parser-0.32.0 lib/ooxml_parser/docx_parser/document_structure/styles.rb
ooxml_parser-0.31.0 lib/ooxml_parser/docx_parser/document_structure/styles.rb
ooxml_parser-0.30.0 lib/ooxml_parser/docx_parser/document_structure/styles.rb