Sha256: 6898f9dd0b7e01a0f9b2c8bbf486874119ed4a30991a5eb28abd4352e5d37560

Contents?: true

Size: 1.05 KB

Versions: 28

Compression:

Stored size: 1.05 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 = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.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

28 entries across 28 versions & 1 rubygems

Version Path
ooxml_parser-0.29.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.28.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.27.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.26.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.25.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.24.0 lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
ooxml_parser-0.23.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.22.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.21.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.20.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.19.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.18.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.18.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.17.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.16.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.15.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.14.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.14.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.14.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb