class OoxmlParser::DocumentBackground
Class for describing Document Background
‘w:background`
Attributes
color1[R]
color2[R]
file_reference[R]
@return [FileReference] image structure
fill[R]
@return [Fill] fill data
size[R]
type[R]
Public Class Methods
new(parent: nil)
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/docx_parser/document_structure/document_background.rb, line 12 def initialize(parent: nil) @color1 = nil @type = 'simple' super end
Public Instance Methods
parse(node)
click to toggle source
Parse DocumentBackground
object @param node [Nokogiri::XML:Element] node to parse @return [DocumentBackground] result of parsing
# File lib/ooxml_parser/docx_parser/document_structure/document_background.rb, line 21 def parse(node) node.attributes.each do |key, value| case key when 'color' @color1 = Color.new(parent: self).parse_hex_string(value.value) end end node.xpath('v:background').each do |second_color| @size = second_color.attribute('targetscreensize').value.sub(',', 'x') unless second_color.attribute('targetscreensize').nil? second_color.xpath('*').each do |node_child| case node_child.name when 'fill' @fill = Fill.new(parent: self).parse(node_child) end end end self end