Class: OoxmlParser::DocxColorScheme

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

Overview

DOCX Color Scheme

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ DocxColorScheme

Returns a new instance of DocxColorScheme.



8
9
10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb', line 8

def initialize(parent: nil)
  @color = Color.new
  @type = :unknown
  super
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb', line 6

def color
  @color
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb', line 6

def type
  @type
end

Instance Method Details

#parse(node) ⇒ DocxColorScheme

Parse DocxColorScheme object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb', line 17

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'solidFill'
      @type = :solid
      @color = Color.new(parent: self).parse_color_model(node_child)
    when 'gradFill'
      @type = :gradient
      @color = GradientColor.new(parent: self).parse(node_child)
    when 'noFill'
      @color = :none
      @type = :none
    when 'srgbClr'
      @color = Color.new(parent: self).parse_hex_string(node_child.attribute('val').value)
    when 'schemeClr'
      @color = Color.new(parent: self).parse_scheme_color(node_child)
    end
  end
  self
end

#to_sString

Returns result of convert of object to string.

Returns:

  • (String)

    result of convert of object to string



39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb', line 39

def to_s
  "Color: #{@color}, type: #{type}"
end