Sha256: 741124c8c6c4d7bf55655e01bccfa8bedd7cbe8ec107490b6373eaffcdc61124

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module OoxmlParser
  # DOCX Color Scheme
  class DocxColorScheme < OOXMLDocumentObject
    attr_accessor :color, :type

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

    # Parse DocxColorScheme object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [DocxColorScheme] result of parsing
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'solidFill'
          @type = :solid
          @color = Color.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.parse_scheme_color(node_child)
        end
      end
      self
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb
ooxml_parser-0.4.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb
ooxml_parser-0.3.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb
ooxml_parser-0.2.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb