Sha256: cdc2031775c5d5170032f4c72917f7c3ec003dec0786b2b0685d45876558958d

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require_relative 'gradient_color/gradient_stop'
require_relative 'gradient_color/linear_gradient'
module OoxmlParser
  # Class for parsing `gradFill` tags
  class GradientColor
    attr_accessor :gradient_stops, :path
    # @return [LinearGradient] content of Linear Gradient
    attr_accessor :linear_gradient

    def initialize(parent: nil)
      @gradient_stops = []
      @parent = parent
    end

    # Parse GradientColor object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [GradientColor] result of parsing
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'gsLst'
          node_child.xpath('*').each do |gradient_stop_node|
            @gradient_stops << GradientStop.new(parent: self).parse(gradient_stop_node)
          end
        when 'path'
          @path = node_child.attribute('path').value.to_sym
        when 'lin'
          @linear_gradient = LinearGradient.new(parent: self).parse(node_child)
        end
      end
      self
    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/colors/presentation_fill/gradient_color.rb
ooxml_parser-0.4.0 lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb
ooxml_parser-0.3.0 lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb
ooxml_parser-0.2.0 lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb