Class: OoxmlParser::GradientColor

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb

Overview

Class for parsing ‘gradFill` tags

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent: nil) ⇒ GradientColor

Returns a new instance of GradientColor.



10
11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb', line 10

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

Instance Attribute Details

#gradient_stopsObject

Returns the value of attribute gradient_stops.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb', line 6

def gradient_stops
  @gradient_stops
end

#linear_gradientLinearGradient

Returns content of Linear Gradient.

Returns:



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb', line 8

def linear_gradient
  @linear_gradient
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb', line 6

def path
  @path
end

Instance Method Details

#parse(node) ⇒ GradientColor

Parse GradientColor object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb', line 18

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