Class: OoxmlParser::PresentationTheme
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::PresentationTheme
- Defined in:
- lib/ooxml_parser/pptx_parser/presentation/presentation_theme.rb
Overview
Class for data for PresentationTheme
Instance Attribute Summary collapse
-
#color_scheme ⇒ Object
Returns the value of attribute color_scheme.
-
#font_scheme ⇒ FontScheme
Font scheme.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ PresentationTheme
constructor
A new instance of PresentationTheme.
-
#parse(file) ⇒ PresentationTheme
Parse PresentationTheme.
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) ⇒ PresentationTheme
Returns a new instance of PresentationTheme.
12 13 14 15 16 |
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_theme.rb', line 12 def initialize(parent: nil) @name = '' @color_scheme = {} super end |
Instance Attribute Details
#color_scheme ⇒ Object
Returns the value of attribute color_scheme.
8 9 10 |
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_theme.rb', line 8 def color_scheme @color_scheme end |
#font_scheme ⇒ FontScheme
Returns font scheme.
10 11 12 |
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_theme.rb', line 10 def font_scheme @font_scheme end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_theme.rb', line 8 def name @name end |
Instance Method Details
#parse(file) ⇒ PresentationTheme
Parse PresentationTheme
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_theme.rb', line 21 def parse(file) root_object.add_to_xmls_stack(file) unless File.exist?(root_object.current_xml) root_object.xmls_stack.pop return end doc = parse_xml(root_object.current_xml) doc.xpath('a:theme').each do |theme_node| @name = theme_node.attribute('name').value if theme_node.attribute('name') theme_node.xpath('a:themeElements/*').each do |theme_element_node| case theme_element_node.name when 'clrScheme' theme_element_node.xpath('*').each do |color_scheme_element| @color_scheme[color_scheme_element.name.to_sym] = ThemeColor.new.parse(color_scheme_element) end @color_scheme[:background1] = @color_scheme[:lt1] @color_scheme[:background2] = @color_scheme[:lt2] @color_scheme[:bg1] = @color_scheme[:lt1] @color_scheme[:bg2] = @color_scheme[:lt2] @color_scheme[:text1] = @color_scheme[:dk1] @color_scheme[:text2] = @color_scheme[:dk2] @color_scheme[:tx1] = @color_scheme[:dk1] @color_scheme[:tx2] = @color_scheme[:dk2] when 'fontScheme' @font_scheme = FontScheme.new(parent: self).parse(theme_element_node) end end end root_object.xmls_stack.pop self end |