class OoxmlParser::DocxColor

Color inside DOCX

Attributes

alpha[RW]
stretching_type[RW]
type[RW]
value[RW]

Public Instance Methods

parse(node) click to toggle source

Parse DocxColor object @param node [Nokogiri::XML:Element] node to parse @return [DocxColor] result of parsing

# 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