Class: OoxmlParser::GradientColor

Inherits:
OOXMLDocumentObject 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

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) ⇒ GradientColor

Returns a new instance of GradientColor.



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

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

Instance Attribute Details

#gradient_stopsObject

Returns the value of attribute gradient_stops.



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

def gradient_stops
  @gradient_stops
end

#linear_gradientLinearGradient

Returns content of Linear Gradient.

Returns:



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

def linear_gradient
  @linear_gradient
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#parse(node) ⇒ GradientColor

Parse GradientColor object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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

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