Class: OoxmlParser::DocumentBackground
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocumentBackground
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/document_background.rb
Overview
Class for describing Document Background ‘w:background`
Instance Attribute Summary collapse
-
#color1 ⇒ Object
readonly
Returns the value of attribute color1.
-
#color2 ⇒ Object
readonly
Returns the value of attribute color2.
-
#file_reference ⇒ FileReference
readonly
Image structure.
-
#fill ⇒ Fill
readonly
Fill data.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ DocumentBackground
constructor
A new instance of DocumentBackground.
-
#parse(node) ⇒ DocumentBackground
Parse DocumentBackground object.
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) ⇒ DocumentBackground
Returns a new instance of DocumentBackground.
12 13 14 15 16 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 12 def initialize(parent: nil) @color1 = nil @type = 'simple' super end |
Instance Attribute Details
#color1 ⇒ Object (readonly)
Returns the value of attribute color1.
6 7 8 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 6 def color1 @color1 end |
#color2 ⇒ Object (readonly)
Returns the value of attribute color2.
6 7 8 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 6 def color2 @color2 end |
#file_reference ⇒ FileReference (readonly)
Returns image structure.
8 9 10 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 8 def file_reference @file_reference end |
#fill ⇒ Fill (readonly)
Returns fill data.
10 11 12 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 10 def fill @fill end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 6 def size @size end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_background.rb', line 6 def type @type end |
Instance Method Details
#parse(node) ⇒ DocumentBackground
Parse DocumentBackground object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 |