Class: OoxmlParser::Background

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/pptx_parser/presentation/slide/background.rb

Overview

Class for parsing ‘bg` tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(type = nil, parent: nil) ⇒ Background

Returns a new instance of Background.



11
12
13
14
# File 'lib/ooxml_parser/pptx_parser/presentation/slide/background.rb', line 11

def initialize(type = nil, parent: nil)
  @type = type
  super(parent: parent)
end

Instance Attribute Details

#fillObject

Returns the value of attribute fill.



7
8
9
# File 'lib/ooxml_parser/pptx_parser/presentation/slide/background.rb', line 7

def fill
  @fill
end

#propertiesBackgroundProperties

Returns properties.

Returns:



9
10
11
# File 'lib/ooxml_parser/pptx_parser/presentation/slide/background.rb', line 9

def properties
  @properties
end

#shade_to_titleObject

Returns the value of attribute shade_to_title.



7
8
9
# File 'lib/ooxml_parser/pptx_parser/presentation/slide/background.rb', line 7

def shade_to_title
  @shade_to_title
end

Instance Method Details

#parse(node) ⇒ Background

Parse Background object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ooxml_parser/pptx_parser/presentation/slide/background.rb', line 19

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'bgPr'
      @properties = BackgroundProperties.new(parent: self).parse(node_child)
    end
  end

  background_properties_node = node.xpath('p:bgPr').first
  if background_properties_node
    @shade_to_title = attribute_enabled?(background_properties_node, 'shadeToTitle')
    @fill = PresentationFill.new(parent: self).parse(background_properties_node)
  end
  self
end