Class: OoxmlParser::TableStyles
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::TableStyles
- Defined in:
- lib/ooxml_parser/pptx_parser/presentation/table_styles.rb
Overview
Class for parsing ‘tableStyles.xml` file
Instance Attribute Summary collapse
-
#table_style_list ⇒ Array<TableStyle>
readonly
List of table styles.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ TableStyles
constructor
A new instance of TableStyles.
-
#parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/tableStyles.xml") ⇒ TableStyles
Parse TableStyles object.
-
#style_by_id(id) ⇒ TableStyle
Style by this id.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ TableStyles
Returns a new instance of TableStyles.
9 10 11 12 |
# File 'lib/ooxml_parser/pptx_parser/presentation/table_styles.rb', line 9 def initialize(parent: nil) @table_style_list = [] super end |
Instance Attribute Details
#table_style_list ⇒ Array<TableStyle> (readonly)
Returns list of table styles.
7 8 9 |
# File 'lib/ooxml_parser/pptx_parser/presentation/table_styles.rb', line 7 def table_style_list @table_style_list end |
Instance Method Details
#parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/tableStyles.xml") ⇒ TableStyles
Parse TableStyles object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ooxml_parser/pptx_parser/presentation/table_styles.rb', line 17 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 |
#style_by_id(id) ⇒ TableStyle
Returns style by this id.
34 35 36 |
# File 'lib/ooxml_parser/pptx_parser/presentation/table_styles.rb', line 34 def style_by_id(id) table_style_list.detect { |style| style.id == id } end |