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

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

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.



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

def alpha
  @alpha
end

#stretching_typeObject

Returns the value of attribute stretching_type.



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

def stretching_type
  @stretching_type
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#parse(node) ⇒ DocxColor

Parse DocxColor object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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
39
40
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb', line 12

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.new(parent: self).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