Class: OoxmlParser::DocumentBackground
- Inherits:
-
Object
- Object
- OoxmlParser::DocumentBackground
- 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
-
#color1 ⇒ Object
Returns the value of attribute color1.
-
#color2 ⇒ Object
Returns the value of attribute color2.
-
#image ⇒ Object
Returns the value of attribute image.
-
#size ⇒ Object
Returns the value of attribute size.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.parse(node) ⇒ DocumentBackground
Parse DocumentBackground object.
Instance Method Summary collapse
-
#initialize(color1 = nil, type = 'simple') ⇒ DocumentBackground
constructor
A new instance of DocumentBackground.
Constructor Details
#initialize(color1 = nil, type = 'simple') ⇒ DocumentBackground
Returns a new instance of DocumentBackground.
6 7 8 9 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 6 def initialize(color1 = nil, type = 'simple') @color1 = color1 @type = type end |
Instance Attribute Details
#color1 ⇒ Object
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 |
#color2 ⇒ Object
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 |
#image ⇒ Object
Returns the value of attribute image.
4 5 6 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 4 def image @image end |
#size ⇒ Object
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 |
#type ⇒ Object
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 |
Class Method Details
.parse(node) ⇒ DocumentBackground
Parse DocumentBackground object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb', line 14 def self.parse(node) background = DocumentBackground.new background.color1 = Color.from_int16(node.attribute('color').value) node.xpath('v:background').each do |second_color| unless second_color.attribute('targetscreensize').nil? background.size = second_color.attribute('targetscreensize').value.sub(',', 'x') end second_color.xpath('v:fill').each do |fill| if !fill.attribute('color2').nil? background.color2 = Color.from_int16(fill.attribute('color2').value.split(' ').first.delete('#')) background.type = fill.attribute('type').value elsif !fill.attribute('id').nil? path_to_media_file = OOXMLDocumentObject.get_link_from_rels(fill.attribute('id').value) path_to_image = OOXMLDocumentObject.copy_media_file("#{OOXMLDocumentObject.root_subfolder}/#{path_to_media_file.gsub('..', '')}") background.image = path_to_image background.type = 'image' end end end background end |