Class: OoxmlParser::ColorScale

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/color_scale.rb

Overview

Class for ‘colorScale` data

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

Returns a new instance of ColorScale.



11
12
13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/color_scale.rb', line 11

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

Instance Attribute Details

#colorsArray<OoxmlColor> (readonly)

Returns list of colors.

Returns:



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/color_scale.rb', line 9

def colors
  @colors
end

#valuesArray<ConditionalFormatValueObject> (readonly)

Returns list of values.

Returns:



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/color_scale.rb', line 7

def values
  @values
end

Instance Method Details

#parse(node) ⇒ ColorScale

Parse ColorScale data

Parameters:

  • node (Nokogiri::XML:Element)

    with ColorScale data

Returns:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/color_scale.rb', line 20

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'cfvo'
      @values << ConditionalFormatValueObject.new(parent: self).parse(node_child)
    when 'color'
      @colors << OoxmlColor.new(parent: self).parse(node_child)
    end
  end
  self
end