Class: OoxmlParser::DocxColor

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb

Overview

Color inside DOCX

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, #initialize, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#alphaObject

Returns the value of attribute alpha.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb', line 5

def alpha
  @alpha
end

#stretching_typeObject

Returns the value of attribute stretching_type.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb', line 5

def stretching_type
  @stretching_type
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb', line 5

def type
  @type
end

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb', line 5

def value
  @value
end

Instance Method Details

#parse(node) ⇒ DocxColor

Parse DocxColor object

Parameters:

  • node to parse

Returns:

  • result of parsing



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb', line 10

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'blipFill'
      @type = :picture
      @value = DocxBlip.new(parent: self).parse(node_child)
      node_child.xpath('*').each do |fill_type_node_child|
        case fill_type_node_child.name
        when 'tile'
          @stretching_type = :tile
        when 'stretch'
          @stretching_type = :stretch
        when 'blip'
          fill_type_node_child.xpath('alphaModFix').each { |alpha_node| @alpha = alpha_node.attribute('amt').value.to_i / 1_000.0 }
        end
      end
    when 'solidFill'
      @type = :solid
      @value = Color.parse_color_model(node_child)
    when 'gradFill'
      @type = :gradient
      @value = GradientColor.new(parent: self).parse(node_child)
    when 'pattFill'
      @type = :pattern
      @value = DocxPatternFill.new(parent: self).parse(node_child)
    end
  end
  self
end