Class: OoxmlParser::DocumentBackground

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb

Overview

Class for describing Document Background w:background

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ DocumentBackground

Returns a new instance of DocumentBackground.



10
11
12
13
14
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 10

def initialize(parent: nil)
  @color1 = nil
  @type = 'simple'
  @parent = parent
end

Instance Attribute Details

#color1Object (readonly)

Returns the value of attribute color1.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 4

def color1
  @color1
end

#color2Object (readonly)

Returns the value of attribute color2.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 4

def color2
  @color2
end

#file_referenceFileReference (readonly)

Returns image structure.

Returns:



6
7
8
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 6

def file_reference
  @file_reference
end

#fillFill (readonly)

Returns fill data.

Returns:

  • (Fill)

    fill data



8
9
10
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 8

def fill
  @fill
end

#sizeObject (readonly)

Returns the value of attribute size.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 4

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 4

def type
  @type
end

Instance Method Details

#parse(node) ⇒ DocumentBackground

Parse DocumentBackground object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 19

def parse(node)
  @color1 = Color.new(parent: self).parse_hex_string(node.attribute('color').value)
  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