class OoxmlParser::TableStyles

Class for parsing `tableStyles.xml` file

Attributes

table_style_list[R]

@return [Array<TableStyle>] list of table styles

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb, line 9
def initialize(parent: nil)
  @table_style_list = []
  super
end

Public Instance Methods

parse(file = " click to toggle source

Parse TableStyles object @param file [Nokogiri::XML:Element] node to parse @return [TableStyles] result of parsing

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb, line 17
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
style_by_id(id) click to toggle source

@param id [String] style to find @return [TableStyle] style by this id

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb, line 34
def style_by_id(id)
  table_style_list.detect { |style| style.id == id }
end