Sha256: 1991d2cea52bcb3a4aa0f3c66079c9b1141a25fbd497d8e701491e3fbf085853

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `tableStyles.xml` file
  class TableStyles < OOXMLDocumentObject
    # @return [Array<TableStyle>] list of table styles
    attr_reader :table_style_list

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

    # Parse TableStyles object
    # @param file [Nokogiri::XML:Element] node to parse
    # @return [TableStyles] result of parsing
    def parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/tableStyles.xml")
      return nil unless File.exist?(file)

      document = parse_xml(file)
      node = document.xpath('*').first

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'tblStyle'
          @table_style_list << TableStyle.new(parent: self).parse(node_child)
        end
      end
      self
    end

    # @param id [String] style to find
    # @return [TableStyle] style by this id
    def style_by_id(id)
      table_style_list.detect { |style| style.id == id }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ooxml_parser-0.38.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.37.1 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.37.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.36.1 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.36.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.35.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.34.2 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.34.1 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.34.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.33.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.32.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.31.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.30.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb