Sha256: b62e7ba96f20dc6604a6c199ed962c0ca90815fcc042388007e19ee21881c293

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 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 = []
      @parent = parent
    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

8 entries across 8 versions & 1 rubygems

Version Path
ooxml_parser-0.8.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.8.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.7.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.7.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.7.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.6.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.5.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
ooxml_parser-0.5.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb